From fc17c7fc37b6fe22784d393825cc3861b0ad9ca4 Mon Sep 17 00:00:00 2001 From: Ryan Lopopolo Date: Fri, 28 Aug 2020 08:36:12 -0700 Subject: [PATCH] Make mapping::lookup const Raises the minimum Rust version to 1.46.0 --- scripts/gen_case_lookups.rb | 4 ++-- src/folding/mapping/lookup.rs | 6 +++--- tests/full_fold_exhaustive.rs | 2 +- tests/full_turkic_fold_exhaustive.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/gen_case_lookups.rb b/scripts/gen_case_lookups.rb index a8567ca5..04abef40 100755 --- a/scripts/gen_case_lookups.rb +++ b/scripts/gen_case_lookups.rb @@ -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) { diff --git a/src/folding/mapping/lookup.rs b/src/folding/mapping/lookup.rs index baa53da0..eabf3750 100644 --- a/src/folding/mapping/lookup.rs +++ b/src/folding/mapping/lookup.rs @@ -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 @@ -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) { diff --git a/tests/full_fold_exhaustive.rs b/tests/full_fold_exhaustive.rs index 59d9082f..2cbae29d 100644 --- a/tests/full_fold_exhaustive.rs +++ b/tests/full_fold_exhaustive.rs @@ -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 diff --git a/tests/full_turkic_fold_exhaustive.rs b/tests/full_turkic_fold_exhaustive.rs index 0b0dd293..e49b8b4c 100644 --- a/tests/full_turkic_fold_exhaustive.rs +++ b/tests/full_turkic_fold_exhaustive.rs @@ -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