Skip to content

Commit

Permalink
Make mapping::lookup const
Browse files Browse the repository at this point in the history
Raises the minimum Rust version to 1.46.0
  • Loading branch information
lopopolo committed Aug 28, 2020
1 parent 9aa7dc5 commit fc17c7f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions scripts/gen_case_lookups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
#[must_use]
#[allow(clippy::match_same_arms)]
#[allow(clippy::too_many_lines)]
pub fn lookup(c: char, mode: Mode) -> Mapping {
let char_bytes = u32::from(c).to_be_bytes();
pub const fn lookup(c: char, mode: Mode) -> Mapping {
let char_bytes = (c as u32).to_be_bytes();
let mid_byte = char_bytes[2];
let high_bytes = u16::from_be_bytes([char_bytes[0], char_bytes[1]]);
match (high_bytes, mid_byte) {
Expand Down
6 changes: 3 additions & 3 deletions src/folding/mapping/lookup.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This source is autogenerated. Do not modify it directly.
// To make modfications to this code, see `scripts/gen_case_lookups.rb`.
//
// Last generated on 2020-08-22 00:52:59 UTC.
// Last generated on 2020-08-28 15:34:55 UTC.
//
// Unicode version:
// CaseFolding-13.0.0.txt
Expand All @@ -13,8 +13,8 @@ use super::{Mapping, Mode};
#[must_use]
#[allow(clippy::match_same_arms)]
#[allow(clippy::too_many_lines)]
pub fn lookup(c: char, mode: Mode) -> Mapping {
let char_bytes = u32::from(c).to_be_bytes();
pub const fn lookup(c: char, mode: Mode) -> Mapping {
let char_bytes = (c as u32).to_be_bytes();
let mid_byte = char_bytes[2];
let high_bytes = u16::from_be_bytes([char_bytes[0], char_bytes[1]]);
match (high_bytes, mid_byte) {
Expand Down
2 changes: 1 addition & 1 deletion tests/full_fold_exhaustive.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This source is autogenerated. Do not modify it directly.
// To make modfications to this code, see `scripts/gen_case_lookups.rb`.
//
// Last generated on 2020-08-22 00:52:59 UTC.
// Last generated on 2020-08-28 15:34:55 UTC.
//
// Unicode version:
// CaseFolding-13.0.0.txt
Expand Down
2 changes: 1 addition & 1 deletion tests/full_turkic_fold_exhaustive.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This source is autogenerated. Do not modify it directly.
// To make modfications to this code, see `scripts/gen_case_lookups.rb`.
//
// Last generated on 2020-08-22 00:52:59 UTC.
// Last generated on 2020-08-28 15:34:55 UTC.
//
// Unicode version:
// CaseFolding-13.0.0.txt
Expand Down

0 comments on commit fc17c7f

Please sign in to comment.