on master help sign in
Mark a few functions as `const`
commitcee7ad781e5f6de249d728425a6283a26bb62dc3 authorBlaž Hrastnik <blaz@mxxn.io> dateSun 24 Oct 2021, 17:28 (5 years ago) parentc913bad
3 files changed+6−6
helix-core/src/line_ending.rs+3−3 helix-core/src/register.rs+2−2 helix-term/src/ui/editor.rs+1−1
helix-core/src/line_ending.rs+3−3
@@ -20,7 +20,7 @@ pub enum LineEnding {
2020
2121impl LineEnding {
2222 #[inline]
23− pub fn len_chars(&self) -> usize {
23+ pub const fn len_chars(&self) -> usize {
2424 match self {
2525 Self::Crlf => 2,
2626 _ => 1,
@@ -28,7 +28,7 @@ impl LineEnding {
2828 }
2929
3030 #[inline]
31− pub fn as_str(&self) -> &'static str {
31+ pub const fn as_str(&self) -> &'static str {
3232 match self {
3333 Self::Crlf => "\u{000D}\u{000A}",
3434 Self::LF => "\u{000A}",
@@ -42,7 +42,7 @@ impl LineEnding {
4242 }
4343
4444 #[inline]
45− pub fn from_char(ch: char) -> Option<LineEnding> {
45+ pub const fn from_char(ch: char) -> Option<LineEnding> {
4646 match ch {
4747 '\u{000A}' => Some(LineEnding::LF),
4848 '\u{000B}' => Some(LineEnding::VT),
helix-core/src/register.rs+2−2
@@ -7,7 +7,7 @@ pub struct Register {
77}
88
99impl Register {
10− pub fn new(name: char) -> Self {
10+ pub const fn new(name: char) -> Self {
1111 Self {
1212 name,
1313 values: Vec::new(),
@@ -18,7 +18,7 @@ impl Register {
1818 Self { name, values }
1919 }
2020
21− pub fn name(&self) -> char {
21+ pub const fn name(&self) -> char {
2222 self.name
2323 }
2424
helix-term/src/ui/editor.rs+1−1
@@ -1106,7 +1106,7 @@ fn canonicalize_key(key: &mut KeyEvent) {
11061106}
11071107
11081108#[inline]
1109−fn abs_diff(a: usize, b: usize) -> usize {
1109+const fn abs_diff(a: usize, b: usize) -> usize {
11101110 if a > b {
11111111 a - b
11121112 } else {