diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /vendor/tinystr/src/ascii.rs | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.tar.xz rustc-5cd5bd4daf55da04d2c8e7c06c3067a027cfbfc2.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/tinystr/src/ascii.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/vendor/tinystr/src/ascii.rs b/vendor/tinystr/src/ascii.rs index 0be1125e3..f39f39b73 100644 --- a/vendor/tinystr/src/ascii.rs +++ b/vendor/tinystr/src/ascii.rs @@ -138,11 +138,6 @@ impl<const N: usize> TinyAsciiStr<N> { #[inline] #[must_use] pub const fn as_bytes(&self) -> &[u8] { - /// core::slice::from_raw_parts(a, b) = core::mem::transmute((a, b)) hack - /// ```compile_fail - /// const unsafe fn canary() { core::slice::from_raw_parts(0 as *const u8, 0); } - /// ``` - const _: () = (); // Safe because `self.bytes.as_slice()` pointer-casts to `&[u8]`, // and changing the length of that slice to self.len() < N is safe. unsafe { core::mem::transmute((self.bytes.as_slice().as_ptr(), self.len())) } @@ -668,7 +663,7 @@ mod test { use rand::seq::SliceRandom; use rand::SeedableRng; - const STRINGS: &[&str] = &[ + const STRINGS: [&str; 26] = [ "Latn", "laTn", "windows", @@ -723,8 +718,8 @@ mod test { T: core::fmt::Debug + core::cmp::PartialEq, { for s in STRINGS - .iter() - .map(|s| s.to_string()) + .into_iter() + .map(str::to_owned) .chain(gen_strings(100, &[3, 4, 5, 8, 12])) { let t = match TinyAsciiStr::<N>::from_str(&s) { @@ -930,7 +925,7 @@ mod test { .map(|c| c.to_ascii_lowercase()) .collect::<String>() }, - |t: TinyAsciiStr<N>| TinyAsciiStr::to_ascii_lowercase(t).to_string(), + |t: TinyAsciiStr<N>| TinyAsciiStr::to_ascii_lowercase(t).as_str().to_owned(), ) } check::<2>(); @@ -954,7 +949,7 @@ mod test { unsafe { r.as_bytes_mut()[0].make_ascii_uppercase() }; r }, - |t: TinyAsciiStr<N>| TinyAsciiStr::to_ascii_titlecase(t).to_string(), + |t: TinyAsciiStr<N>| TinyAsciiStr::to_ascii_titlecase(t).as_str().to_owned(), ) } check::<2>(); @@ -974,7 +969,7 @@ mod test { .map(|c| c.to_ascii_uppercase()) .collect::<String>() }, - |t: TinyAsciiStr<N>| TinyAsciiStr::to_ascii_uppercase(t).to_string(), + |t: TinyAsciiStr<N>| TinyAsciiStr::to_ascii_uppercase(t).as_str().to_owned(), ) } check::<2>(); |