diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:50 +0000 |
commit | 2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 (patch) | |
tree | d325add32978dbdc1db975a438b3a77d571b1ab8 /vendor/tinystr/src | |
parent | Releasing progress-linux version 1.68.2+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.tar.xz rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.zip |
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/tinystr/src')
-rw-r--r-- | vendor/tinystr/src/ascii.rs | 17 | ||||
-rw-r--r-- | vendor/tinystr/src/error.rs | 3 | ||||
-rw-r--r-- | vendor/tinystr/src/lib.rs | 8 |
3 files changed, 13 insertions, 15 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>(); diff --git a/vendor/tinystr/src/error.rs b/vendor/tinystr/src/error.rs index 03901431c..7910f8b48 100644 --- a/vendor/tinystr/src/error.rs +++ b/vendor/tinystr/src/error.rs @@ -4,6 +4,9 @@ use displaydoc::Display; +#[cfg(feature = "std")] +impl std::error::Error for TinyStrError {} + #[derive(Display, Debug, PartialEq, Eq)] #[non_exhaustive] pub enum TinyStrError { diff --git a/vendor/tinystr/src/lib.rs b/vendor/tinystr/src/lib.rs index 96018b8b2..7745da0e5 100644 --- a/vendor/tinystr/src/lib.rs +++ b/vendor/tinystr/src/lib.rs @@ -21,8 +21,8 @@ //! assert_eq!(s1.to_ascii_uppercase(), "TEST"); //! assert_eq!(s1.to_ascii_lowercase(), "test"); //! assert_eq!(s1.to_ascii_titlecase(), "Test"); -//! assert_eq!(s1.is_ascii_alphanumeric(), true); -//! assert_eq!(s1.is_ascii_numeric(), false); +//! assert!(s1.is_ascii_alphanumeric()); +//! assert!(!s1.is_ascii_numeric()); //! //! let s2 = TinyAsciiStr::<8>::try_from_raw(*b"New York") //! .expect("Failed to parse."); @@ -31,7 +31,7 @@ //! assert_eq!(s2.to_ascii_uppercase(), "NEW YORK"); //! assert_eq!(s2.to_ascii_lowercase(), "new york"); //! assert_eq!(s2.to_ascii_titlecase(), "New york"); -//! assert_eq!(s2.is_ascii_alphanumeric(), false); +//! assert!(!s2.is_ascii_alphanumeric()); //! ``` //! //! # Details @@ -52,7 +52,7 @@ //! [`ICU4X`]: ../icu/index.html // https://github.com/unicode-org/icu4x/blob/main/docs/process/boilerplate.md#library-annotations -#![cfg_attr(not(test), no_std)] +#![cfg_attr(not(any(test, feature = "std")), no_std)] #![cfg_attr( not(test), deny( |