| 1 | #[cfg(feature = "alloc")] |
| 2 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::ToOwnedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/ToOwned#; |
| 3 | #[cfg(feature = "alloc")] |
| 4 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::boxedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/::Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#; |
| 5 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/; |
| 6 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#, IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#}; |
| 7 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#, RangeFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#, RangeFullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#, RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#, RangeTorust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#, RangeToInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeToInclusive#}; |
| 8 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/::{selfrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/, Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#, IterMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/IterMut#, SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#}; |
| 9 | #[cfg(feature = "std")] |
| 10 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#; |
| 11 | #[cfg(feature = "std")] |
| 12 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#; |
| 13 | |
| 14 | use ascii_char::AsciiChar; |
| 15 | #[cfg(feature = "alloc")] |
| 16 | use ascii_string::AsciiString; |
| 17 | |
| 18 | /// [`AsciiStr`] represents a byte or string slice that only contains ASCII characters. |
| 19 | /// |
| 20 | /// It wraps an `[AsciiChar]` and implements many of `str`s methods and traits. |
| 21 | /// |
| 22 | /// It can be created by a checked conversion from a `str` or `[u8]`, or borrowed from an |
| 23 | /// `AsciiString`. |
| 24 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/macros/Hash:)] |
| 25 | #[repr(transparent)] |
| 26 | pub struct AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 27 | slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice.: [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#], |
| 28 | } |
| 29 | |
| 30 | impl AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 31 | /// Converts `&self` to a `&str` slice. |
| 32 | #[inline] |
| 33 | #[must_use] |
| 34 | pub fn as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_str().(&self) -> &str { |
| 35 | // SAFETY: All variants of `AsciiChar` are valid bytes for a `str`. |
| 36 | unsafe { &*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().(self as *const AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# as *const str) } |
| 37 | } |
| 38 | |
| 39 | /// Converts `&self` into a byte slice. |
| 40 | #[inline] |
| 41 | #[must_use] |
| 42 | pub fn as_bytesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_bytes().(&self) -> &[u8] { |
| 43 | // SAFETY: All variants of `AsciiChar` are valid `u8`, given they're `repr(u8)`. |
| 44 | unsafe { &*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().(self as *const AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# as *const [u8]) } |
| 45 | } |
| 46 | |
| 47 | /// Returns the entire string as slice of `AsciiChar`s. |
| 48 | #[inline] |
| 49 | #[must_use] |
| 50 | pub const fn as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().(&self) -> &[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] { |
| 51 | &self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice. |
| 52 | } |
| 53 | |
| 54 | /// Returns the entire string as mutable slice of `AsciiChar`s. |
| 55 | #[inline] |
| 56 | #[must_use] |
| 57 | pub fn as_mut_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_mut_slice().(&mut self) -> &mut [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] { |
| 58 | &mut self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice. |
| 59 | } |
| 60 | |
| 61 | /// Returns a raw pointer to the `AsciiStr`'s buffer. |
| 62 | /// |
| 63 | /// The caller must ensure that the slice outlives the pointer this function returns, or else it |
| 64 | /// will end up pointing to garbage. Modifying the `AsciiStr` may cause it's buffer to be |
| 65 | /// reallocated, which would also make any pointers to it invalid. |
| 66 | #[inline] |
| 67 | #[must_use] |
| 68 | pub const fn as_ptrrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_ptr().(&self) -> *const AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar# { |
| 69 | self.as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().().as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().() |
| 70 | } |
| 71 | |
| 72 | /// Returns an unsafe mutable pointer to the `AsciiStr`'s buffer. |
| 73 | /// |
| 74 | /// The caller must ensure that the slice outlives the pointer this function returns, or else it |
| 75 | /// will end up pointing to garbage. Modifying the `AsciiStr` may cause it's buffer to be |
| 76 | /// reallocated, which would also make any pointers to it invalid. |
| 77 | #[inline] |
| 78 | #[must_use] |
| 79 | pub fn as_mut_ptrrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_mut_ptr().(&mut self) -> *mut AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar# { |
| 80 | self.as_mut_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_mut_slice().().as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().() |
| 81 | } |
| 82 | |
| 83 | /// Copies the content of this `AsciiStr` into an owned `AsciiString`. |
| 84 | #[cfg(feature = "alloc")] |
| 85 | #[must_use] |
| 86 | pub fn to_ascii_stringrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]to_ascii_string().(&self) -> AsciiStringrust-analyzer cargo ascii 1.1.0 ascii_string/AsciiString# { |
| 87 | AsciiStringrust-analyzer cargo ascii 1.1.0 ascii_string/AsciiString#::fromrust-analyzer cargo ascii 1.1.0 ascii_string/impl#[AsciiString][`From<Vec<AsciiChar>>`]from().(self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice..to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().()) |
| 88 | } |
| 89 | |
| 90 | /// Converts anything that can represent a byte slice into an `AsciiStr`. |
| 91 | /// |
| 92 | /// # Errors |
| 93 | /// If `bytes` contains a non-ascii byte, `Err` will be returned |
| 94 | /// |
| 95 | /// # Examples |
| 96 | /// ``` |
| 97 | /// # use ascii::AsciiStr; |
| 98 | /// let foo = AsciiStr::from_ascii(b"foo"); |
| 99 | /// let err = AsciiStr::from_ascii("Ŋ"); |
| 100 | /// assert_eq!(foo.unwrap().as_str(), "foo"); |
| 101 | /// assert_eq!(err.unwrap_err().valid_up_to(), 0); |
| 102 | /// ``` |
| 103 | #[inline] |
| 104 | pub fn from_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii().<B>(bytes: &B) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 105 | where |
| 106 | B: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]> + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 107 | { |
| 108 | bytes.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str().() |
| 109 | } |
| 110 | |
| 111 | /// Converts anything that can be represented as a byte slice to an `AsciiStr` without checking |
| 112 | /// for non-ASCII characters.. |
| 113 | /// |
| 114 | /// # Safety |
| 115 | /// If any of the bytes in `bytes` do not represent valid ascii characters, calling |
| 116 | /// this function is undefined behavior. |
| 117 | /// |
| 118 | /// # Examples |
| 119 | /// ``` |
| 120 | /// # use ascii::AsciiStr; |
| 121 | /// let foo = unsafe { AsciiStr::from_ascii_unchecked(&b"foo"[..]) }; |
| 122 | /// assert_eq!(foo.as_str(), "foo"); |
| 123 | /// ``` |
| 124 | #[inline] |
| 125 | #[must_use] |
| 126 | pub unsafe fn from_ascii_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii_unchecked().(bytes: &[u8]) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 127 | // SAFETY: Caller guarantees all bytes in `bytes` are valid |
| 128 | // ascii characters. |
| 129 | unsafe { bytes.as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str_unchecked().() } |
| 130 | } |
| 131 | |
| 132 | /// Returns the number of characters / bytes in this ASCII sequence. |
| 133 | /// |
| 134 | /// # Examples |
| 135 | /// ``` |
| 136 | /// # use ascii::AsciiStr; |
| 137 | /// let s = AsciiStr::from_ascii("foo").unwrap(); |
| 138 | /// assert_eq!(s.len(), 3); |
| 139 | /// ``` |
| 140 | #[inline] |
| 141 | #[must_use] |
| 142 | pub const fn lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().(&self) -> usize { |
| 143 | self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() |
| 144 | } |
| 145 | |
| 146 | /// Returns true if the ASCII slice contains zero bytes. |
| 147 | /// |
| 148 | /// # Examples |
| 149 | /// ``` |
| 150 | /// # use ascii::AsciiStr; |
| 151 | /// let mut empty = AsciiStr::from_ascii("").unwrap(); |
| 152 | /// let mut full = AsciiStr::from_ascii("foo").unwrap(); |
| 153 | /// assert!(empty.is_empty()); |
| 154 | /// assert!(!full.is_empty()); |
| 155 | /// ``` |
| 156 | #[inline] |
| 157 | #[must_use] |
| 158 | pub const fn is_emptyrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]is_empty().(&self) -> bool { |
| 159 | self.lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 |
| 160 | } |
| 161 | |
| 162 | /// Returns an iterator over the characters of the `AsciiStr`. |
| 163 | #[inline] |
| 164 | #[must_use] |
| 165 | pub fn charsrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars().(&self) -> Charsrust-analyzer cargo ascii 1.1.0 ascii_str/Chars# { |
| 166 | Charsrust-analyzer cargo ascii 1.1.0 ascii_str/Chars#(self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) |
| 167 | } |
| 168 | |
| 169 | /// Returns an iterator over the characters of the `AsciiStr` which allows you to modify the |
| 170 | /// value of each `AsciiChar`. |
| 171 | #[inline] |
| 172 | #[must_use] |
| 173 | pub fn chars_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars_mut().(&mut self) -> CharsMutrust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut# { |
| 174 | CharsMutrust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut#(self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice..iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().()) |
| 175 | } |
| 176 | |
| 177 | /// Returns an iterator over parts of the `AsciiStr` separated by a character. |
| 178 | /// |
| 179 | /// # Examples |
| 180 | /// ``` |
| 181 | /// # use ascii::{AsciiStr, AsciiChar}; |
| 182 | /// let words = AsciiStr::from_ascii("apple banana lemon").unwrap() |
| 183 | /// .split(AsciiChar::Space) |
| 184 | /// .map(|a| a.as_str()) |
| 185 | /// .collect::<Vec<_>>(); |
| 186 | /// assert_eq!(words, ["apple", "banana", "lemon"]); |
| 187 | /// ``` |
| 188 | #[must_use] |
| 189 | pub fn splitrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]split().(&self, on: AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#) -> impl DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> { |
| 190 | Splitrust-analyzer cargo ascii 1.1.0 ascii_str/Split# { |
| 191 | onrust-analyzer cargo ascii 1.1.0 ascii_str/Split#on., |
| 192 | endedrust-analyzer cargo ascii 1.1.0 ascii_str/Split#ended.: false, |
| 193 | charsrust-analyzer cargo ascii 1.1.0 ascii_str/Split#chars.: self.charsrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars().(), |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | /// Returns an iterator over the lines of the `AsciiStr`, which are themselves `AsciiStr`s. |
| 198 | /// |
| 199 | /// Lines are ended with either `LineFeed` (`\n`), or `CarriageReturn` then `LineFeed` (`\r\n`). |
| 200 | /// |
| 201 | /// The final line ending is optional. |
| 202 | #[inline] |
| 203 | #[must_use] |
| 204 | pub fn linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().(&self) -> impl DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> { |
| 205 | Linesrust-analyzer cargo ascii 1.1.0 ascii_str/Lines# { stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string.: self } |
| 206 | } |
| 207 | |
| 208 | /// Returns an ASCII string slice with leading and trailing whitespace removed. |
| 209 | /// |
| 210 | /// # Examples |
| 211 | /// ``` |
| 212 | /// # use ascii::AsciiStr; |
| 213 | /// let example = AsciiStr::from_ascii(" \twhite \tspace \t").unwrap(); |
| 214 | /// assert_eq!("white \tspace", example.trim()); |
| 215 | /// ``` |
| 216 | #[must_use] |
| 217 | pub fn trimrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]trim().(&self) -> &Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr] { |
| 218 | self.trim_startrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]trim_start().().trim_endrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]trim_end().() |
| 219 | } |
| 220 | |
| 221 | /// Returns an ASCII string slice with leading whitespace removed. |
| 222 | /// |
| 223 | /// # Examples |
| 224 | /// ``` |
| 225 | /// # use ascii::AsciiStr; |
| 226 | /// let example = AsciiStr::from_ascii(" \twhite \tspace \t").unwrap(); |
| 227 | /// assert_eq!("white \tspace \t", example.trim_start()); |
| 228 | /// ``` |
| 229 | #[must_use] |
| 230 | pub fn trim_startrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]trim_start().(&self) -> &Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr] { |
| 231 | let whitespace_len = self |
| 232 | .charsrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars().() |
| 233 | .positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#position().(|ch| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().ch.is_whitespacerust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar]is_whitespace().()) |
| 234 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| self.lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().()); |
| 235 | |
| 236 | // SAFETY: `whitespace_len` is `0..=len`, which is at most `len`, which is a valid empty slice. |
| 237 | unsafe { self.as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().().get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(whitespace_len..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() } |
| 238 | } |
| 239 | |
| 240 | /// Returns an ASCII string slice with trailing whitespace removed. |
| 241 | /// |
| 242 | /// # Examples |
| 243 | /// ``` |
| 244 | /// # use ascii::AsciiStr; |
| 245 | /// let example = AsciiStr::from_ascii(" \twhite \tspace \t").unwrap(); |
| 246 | /// assert_eq!(" \twhite \tspace", example.trim_end()); |
| 247 | /// ``` |
| 248 | #[must_use] |
| 249 | pub fn trim_endrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]trim_end().(&self) -> &Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr] { |
| 250 | // Number of whitespace characters counting from the end |
| 251 | let whitespace_len = self |
| 252 | .charsrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars().() |
| 253 | .revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() |
| 254 | .positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#position().(|ch| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().ch.is_whitespacerust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar]is_whitespace().()) |
| 255 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| self.lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().()); |
| 256 | |
| 257 | // SAFETY: `whitespace_len` is `0..=len`, which is at most `len`, which is a valid empty slice, and at least `0`, which is the whole slice. |
| 258 | unsafe { |
| 259 | self.as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().() |
| 260 | .get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#self.lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().whitespace_len) |
| 261 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | /// Compares two strings case-insensitively. |
| 266 | #[must_use] |
| 267 | pub fn eq_ignore_ascii_caserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]eq_ignore_ascii_case().(&self, other: &Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]) -> bool { |
| 268 | self.lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().other.lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().() |
| 269 | && self |
| 270 | .charsrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars().() |
| 271 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(other.charsrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars().()) |
| 272 | .allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(|(ch, other_ch)| ch.eq_ignore_ascii_caserust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar]eq_ignore_ascii_case().(&other_ch)) |
| 273 | } |
| 274 | |
| 275 | /// Replaces lowercase letters with their uppercase equivalent. |
| 276 | pub fn make_ascii_uppercaserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]make_ascii_uppercase().(&mut self) { |
| 277 | for ch in self.chars_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars_mut().() { |
| 278 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().ch = ch.to_ascii_uppercaserust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar]to_ascii_uppercase().(); |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | /// Replaces uppercase letters with their lowercase equivalent. |
| 283 | pub fn make_ascii_lowercaserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]make_ascii_lowercase().(&mut self) { |
| 284 | for ch in self.chars_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars_mut().() { |
| 285 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().ch = ch.to_ascii_lowercaserust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar]to_ascii_lowercase().(); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | /// Returns a copy of this string where letters 'a' to 'z' are mapped to 'A' to 'Z'. |
| 290 | #[cfg(feature = "alloc")] |
| 291 | #[must_use] |
| 292 | pub fn to_ascii_uppercaserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]to_ascii_uppercase().(&self) -> AsciiStringrust-analyzer cargo ascii 1.1.0 ascii_string/AsciiString# { |
| 293 | let mut ascii_string = self.to_ascii_stringrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]to_ascii_string().(); |
| 294 | ascii_string.make_ascii_uppercaserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]make_ascii_uppercase().(); |
| 295 | ascii_string |
| 296 | } |
| 297 | |
| 298 | /// Returns a copy of this string where letters 'A' to 'Z' are mapped to 'a' to 'z'. |
| 299 | #[cfg(feature = "alloc")] |
| 300 | #[must_use] |
| 301 | pub fn to_ascii_lowercaserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]to_ascii_lowercase().(&self) -> AsciiStringrust-analyzer cargo ascii 1.1.0 ascii_string/AsciiString# { |
| 302 | let mut ascii_string = self.to_ascii_stringrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]to_ascii_string().(); |
| 303 | ascii_string.make_ascii_lowercaserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]make_ascii_lowercase().(); |
| 304 | ascii_string |
| 305 | } |
| 306 | |
| 307 | /// Returns the first character if the string is not empty. |
| 308 | #[inline] |
| 309 | #[must_use] |
| 310 | pub fn firstrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]first().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#> { |
| 311 | self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice..firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().().copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]copied().() |
| 312 | } |
| 313 | |
| 314 | /// Returns the last character if the string is not empty. |
| 315 | #[inline] |
| 316 | #[must_use] |
| 317 | pub fn lastrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]last().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#> { |
| 318 | self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice..lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]copied().() |
| 319 | } |
| 320 | |
| 321 | /// Converts a [`Box<AsciiStr>`] into a [`AsciiString`] without copying or allocating. |
| 322 | #[cfg(feature = "alloc")] |
| 323 | #[inline] |
| 324 | #[must_use] |
| 325 | pub fn into_ascii_stringrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]into_ascii_string().(self: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]>) -> AsciiStringrust-analyzer cargo ascii 1.1.0 ascii_string/AsciiString# { |
| 326 | let slice = Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::<[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]>::fromrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Box<[AsciiChar]>`][`From<Box<AsciiStr>>`]from().(self); |
| 327 | AsciiStringrust-analyzer cargo ascii 1.1.0 ascii_string/AsciiString#::fromrust-analyzer cargo ascii 1.1.0 ascii_string/impl#[AsciiString][`From<Vec<AsciiChar>>`]from().(slice.into_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]into_vec().()) |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | macro_rules! impl_partial_eqrust-analyzer cargo ascii 1.1.0 ascii_str/impl_partial_eq! { |
| 332 | ($wider: ty) => { |
| 333 | impl PartialEq<$wider> for AsciiStr { |
| 334 | #[inline] |
| 335 | fn eq(&self, other: &$wider) -> bool { |
| 336 | <AsciiStr as AsRef<$wider>>::as_ref(self) == other |
| 337 | } |
| 338 | } |
| 339 | impl PartialEq<AsciiStr> for $wider { |
| 340 | #[inline] |
| 341 | fn eq(&self, other: &AsciiStr) -> bool { |
| 342 | self == <AsciiStr as AsRef<$wider>>::as_ref(other) |
| 343 | } |
| 344 | } |
| 345 | }; |
| 346 | } |
| 347 | |
| 348 | impl_partial_eqrust-analyzer cargo ascii 1.1.0 ascii_str/impl_partial_eq!! {str} |
| 349 | impl_partial_eqrust-analyzer cargo ascii 1.1.0 ascii_str/impl_partial_eq!! {[u8]} |
| 350 | impl_partial_eqrust-analyzer cargo ascii 1.1.0 ascii_str/impl_partial_eq!! {[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]} |
| 351 | |
| 352 | #[cfg(feature = "alloc")] |
| 353 | impl ToOwnedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/ToOwned# for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 354 | type Ownedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][ToOwned]Owned# = AsciiStringrust-analyzer cargo ascii 1.1.0 ascii_string/AsciiString#; |
| 355 | |
| 356 | #[inline] |
| 357 | fn to_ownedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][ToOwned]to_owned().(&self) -> AsciiStringrust-analyzer cargo ascii 1.1.0 ascii_string/AsciiString# { |
| 358 | self.to_ascii_stringrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]to_ascii_string().() |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[u8]> for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 363 | #[inline] |
| 364 | fn as_refrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][`AsRef<[u8]>`]as_ref().(&self) -> &[u8] { |
| 365 | self.as_bytesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_bytes().() |
| 366 | } |
| 367 | } |
| 368 | impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str> for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 369 | #[inline] |
| 370 | fn as_refrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][`AsRef<str>`]as_ref().(&self) -> &str { |
| 371 | self.as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_str().() |
| 372 | } |
| 373 | } |
| 374 | impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]> for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 375 | #[inline] |
| 376 | fn as_refrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][`AsRef<[AsciiChar]>`]as_ref().(&self) -> &[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] { |
| 377 | &self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice. |
| 378 | } |
| 379 | } |
| 380 | impl AsMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsMut#<[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]> for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 381 | #[inline] |
| 382 | fn as_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][`AsMut<[AsciiChar]>`]as_mut().(&mut self) -> &mut [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] { |
| 383 | &mut self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice. |
| 384 | } |
| 385 | } |
| 386 | |
| 387 | impl Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for &'static AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 388 | #[inline] |
| 389 | fn defaultrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'static AsciiStr`][Default]default().() -> &'static AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 390 | Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#::fromrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a AsciiStr`][`From<&'a [AsciiChar]>`]from().(&[] as &[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]) |
| 391 | } |
| 392 | } |
| 393 | impl<'a> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'a [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]> for &'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 394 | #[inline] |
| 395 | fn fromrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a AsciiStr`][`From<&'a [AsciiChar]>`]from().(slice: &[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 396 | let ptr = slice as *const [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] as *const AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#; |
| 397 | unsafe { &*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().ptr } |
| 398 | } |
| 399 | } |
| 400 | impl<'a> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'a mut [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]> for &'a mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 401 | #[inline] |
| 402 | fn fromrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut AsciiStr`][`From<&'a mut [AsciiChar]>`]from().(slice: &mut [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]) -> &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 403 | let ptr = slice as *mut [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] as *mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#; |
| 404 | unsafe { &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().ptr } |
| 405 | } |
| 406 | } |
| 407 | #[cfg(feature = "alloc")] |
| 408 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]>> for Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> { |
| 409 | #[inline] |
| 410 | fn fromrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Box<AsciiStr>`][`From<Box<[AsciiChar]>>`]from().(owned: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]>) -> Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> { |
| 411 | let ptr = Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::into_rawrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]into_raw().(owned) as *mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#; |
| 412 | unsafe { Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::from_rawrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]from_raw().(ptr) } |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 417 | #[inline] |
| 418 | fn as_refrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][`AsRef<Self>`]as_ref().(&self) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 419 | self |
| 420 | } |
| 421 | } |
| 422 | impl AsMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsMut#<AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 423 | #[inline] |
| 424 | fn as_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][`AsMut<Self>`]as_mut().(&mut self) -> &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 425 | self |
| 426 | } |
| 427 | } |
| 428 | impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> for [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] { |
| 429 | #[inline] |
| 430 | fn as_refrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][`AsRef<AsciiStr>`]as_ref().(&self) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 431 | self.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 432 | } |
| 433 | } |
| 434 | impl AsMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsMut#<AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> for [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] { |
| 435 | #[inline] |
| 436 | fn as_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][`AsMut<AsciiStr>`]as_mut().(&mut self) -> &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 437 | self.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | impl<'a> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> for &'a [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] { |
| 442 | #[inline] |
| 443 | fn fromrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a [AsciiChar]`][`From<&'a AsciiStr>`]from().(astr: &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#) -> &[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] { |
| 444 | &astr.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice. |
| 445 | } |
| 446 | } |
| 447 | impl<'a> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'a mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> for &'a mut [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] { |
| 448 | #[inline] |
| 449 | fn fromrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut [AsciiChar]`][`From<&'a mut AsciiStr>`]from().(astr: &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#) -> &mut [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] { |
| 450 | &mut astr.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice. |
| 451 | } |
| 452 | } |
| 453 | impl<'a> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> for &'a [u8] { |
| 454 | #[inline] |
| 455 | fn fromrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a [u8]`][`From<&'a AsciiStr>`]from().(astr: &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#) -> &[u8] { |
| 456 | astr.as_bytesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_bytes().() |
| 457 | } |
| 458 | } |
| 459 | impl<'a> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> for &'a str { |
| 460 | #[inline] |
| 461 | fn fromrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a str`][`From<&'a AsciiStr>`]from().(astr: &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#) -> &str { |
| 462 | astr.as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_str().() |
| 463 | } |
| 464 | } |
| 465 | macro_rules! widen_boxrust-analyzer cargo ascii 1.1.0 ascii_str/widen_box! { |
| 466 | ($wider: ty) => { |
| 467 | #[cfg(feature = "alloc")] |
| 468 | impl From<Box<AsciiStr>> for Box<$wider> { |
| 469 | #[inline] |
| 470 | fn from(owned: Box<AsciiStr>) -> Box<$wider> { |
| 471 | let ptr = Box::into_raw(owned) as *mut $wider; |
| 472 | unsafe { Box::from_raw(ptr) } |
| 473 | } |
| 474 | } |
| 475 | }; |
| 476 | } |
| 477 | widen_boxrust-analyzer cargo ascii 1.1.0 ascii_str/widen_box!! {[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]} |
| 478 | widen_boxrust-analyzer cargo ascii 1.1.0 ascii_str/widen_box!! {[u8]} |
| 479 | widen_boxrust-analyzer cargo ascii 1.1.0 ascii_str/widen_box!! {str} |
| 480 | |
| 481 | // allows &AsciiChar to be used by generic AsciiString Extend and FromIterator |
| 482 | impl AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> for AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar# { |
| 483 | fn as_refrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiChar][`AsRef<AsciiStr>`]as_ref().(&self) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 484 | slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/::from_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/raw/from_ref().(self).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 489 | #[inline] |
| 490 | fn fmtrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 491 | fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[str][Display]fmt().(self.as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_str().(), f) |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 496 | #[inline] |
| 497 | fn fmtrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 498 | fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[str][Debug]fmt().(self.as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_str().(), f) |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | macro_rules! impl_indexrust-analyzer cargo ascii 1.1.0 ascii_str/impl_index! { |
| 503 | ($idx:ty) => { |
| 504 | #[allow(clippy::indexing_slicing)] // In `Index`, if it's out of bounds, panic is the default |
| 505 | impl Index<$idx> for AsciiStr { |
| 506 | type Output = AsciiStr; |
| 507 | |
| 508 | #[inline] |
| 509 | fn index(&self, index: $idx) -> &AsciiStr { |
| 510 | self.slice[index].as_ref() |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | #[allow(clippy::indexing_slicing)] // In `IndexMut`, if it's out of bounds, panic is the default |
| 515 | impl IndexMut<$idx> for AsciiStr { |
| 516 | #[inline] |
| 517 | fn index_mut(&mut self, index: $idx) -> &mut AsciiStr { |
| 518 | self.slice[index].as_mut() |
| 519 | } |
| 520 | } |
| 521 | }; |
| 522 | } |
| 523 | |
| 524 | impl_indexrust-analyzer cargo ascii 1.1.0 ascii_str/impl_index!! { Rangerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#<usize> } |
| 525 | impl_indexrust-analyzer cargo ascii 1.1.0 ascii_str/impl_index!! { RangeTorust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#<usize> } |
| 526 | impl_indexrust-analyzer cargo ascii 1.1.0 ascii_str/impl_index!! { RangeFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#<usize> } |
| 527 | impl_indexrust-analyzer cargo ascii 1.1.0 ascii_str/impl_index!! { RangeFullrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull# } |
| 528 | impl_indexrust-analyzer cargo ascii 1.1.0 ascii_str/impl_index!! { RangeInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#<usize> } |
| 529 | impl_indexrust-analyzer cargo ascii 1.1.0 ascii_str/impl_index!! { RangeToInclusiverust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeToInclusive#<usize> } |
| 530 | |
| 531 | #[allow(clippy::indexing_slicing)] // In `Index`, if it's out of bounds, panic is the default |
| 532 | impl Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#<usize> for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 533 | type Outputrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][`Index<usize>`]Output# = AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#; |
| 534 | |
| 535 | #[inline] |
| 536 | fn indexrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][`Index<usize>`]index().(&self, index: usize) -> &AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar# { |
| 537 | &self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/impl#[`[T]`][`Index<I>`]index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/impl#[`[T]`][`Index<I>`]index(). |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | #[allow(clippy::indexing_slicing)] // In `IndexMut`, if it's out of bounds, panic is the default |
| 542 | impl IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#<usize> for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 543 | #[inline] |
| 544 | fn index_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][`IndexMut<usize>`]index_mut().(&mut self, index: usize) -> &mut AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar# { |
| 545 | &mut self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/impl#[`[T]`][`IndexMut<I>`]index_mut().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/impl#[`[T]`][`IndexMut<I>`]index_mut(). |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | /// Produces references for compatibility with `[u8]`. |
| 550 | /// |
| 551 | /// (`str` doesn't implement `IntoIterator` for its references, |
| 552 | /// so there is no compatibility to lose.) |
| 553 | impl<'a> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for &'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 554 | type Itemrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a AsciiStr`][IntoIterator]Item# = &'a AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#; |
| 555 | type IntoIterrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a AsciiStr`][IntoIterator]IntoIter# = CharsRefrust-analyzer cargo ascii 1.1.0 ascii_str/CharsRef#<'a>; |
| 556 | #[inline] |
| 557 | fn into_iterrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a AsciiStr`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a AsciiStr`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# { |
| 558 | CharsRefrust-analyzer cargo ascii 1.1.0 ascii_str/CharsRef#(self.as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().().iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | impl<'a> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for &'a mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 563 | type Itemrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut AsciiStr`][IntoIterator]Item# = &'a mut AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#; |
| 564 | type IntoIterrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut AsciiStr`][IntoIterator]IntoIter# = CharsMutrust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut#<'a>; |
| 565 | #[inline] |
| 566 | fn into_iterrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut AsciiStr`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut AsciiStr`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# { |
| 567 | self.chars_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars_mut().() |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | /// A copying iterator over the characters of an `AsciiStr`. |
| 572 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 573 | pub struct Charsrust-analyzer cargo ascii 1.1.0 ascii_str/Chars#<'a>(Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<'a, AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#>); |
| 574 | impl<'a> Charsrust-analyzer cargo ascii 1.1.0 ascii_str/Chars#<'a> { |
| 575 | /// Returns the ascii string slice with the remaining characters. |
| 576 | #[must_use] |
| 577 | pub fn as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Chars<'a>`]as_str().(&self) -> &'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 578 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/Chars#0..as_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`]as_slice().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 579 | } |
| 580 | } |
| 581 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Charsrust-analyzer cargo ascii 1.1.0 ascii_str/Chars#<'a> { |
| 582 | type Itemrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Chars<'a>`][Iterator]Item# = AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#; |
| 583 | #[inline] |
| 584 | fn nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Chars<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#> { |
| 585 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/Chars#0..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().().copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]copied().() |
| 586 | } |
| 587 | fn size_hintrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Chars<'a>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 588 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/Chars#0..size_hintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]size_hint().() |
| 589 | } |
| 590 | } |
| 591 | impl<'a> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for Charsrust-analyzer cargo ascii 1.1.0 ascii_str/Chars#<'a> { |
| 592 | #[inline] |
| 593 | fn next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Chars<'a>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#> { |
| 594 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/Chars#0..next_backrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][DoubleEndedIterator]next_back().().copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]copied().() |
| 595 | } |
| 596 | } |
| 597 | impl<'a> ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator# for Charsrust-analyzer cargo ascii 1.1.0 ascii_str/Chars#<'a> { |
| 598 | fn lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Chars<'a>`][ExactSizeIterator]len().(&self) -> usize { |
| 599 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/Chars#0..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'_, T>`][ExactSizeIterator]len().() |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | /// A mutable iterator over the characters of an `AsciiStr`. |
| 604 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 605 | pub struct CharsMutrust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut#<'a>(IterMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/IterMut#<'a, AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#>); |
| 606 | impl<'a> CharsMutrust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut#<'a> { |
| 607 | /// Returns the ascii string slice with the remaining characters. |
| 608 | #[must_use] |
| 609 | pub fn into_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`CharsMut<'a>`]into_str().(self) -> &'a mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 610 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut#0..into_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`IterMut<'a, T>`]into_slice().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 611 | } |
| 612 | } |
| 613 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for CharsMutrust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut#<'a> { |
| 614 | type Itemrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`CharsMut<'a>`][Iterator]Item# = &'a mut AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#; |
| 615 | #[inline] |
| 616 | fn nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`CharsMut<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a mut AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#> { |
| 617 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut#0..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`IterMut<'a, T>`][Iterator]next().() |
| 618 | } |
| 619 | fn size_hintrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`CharsMut<'a>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 620 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut#0..size_hintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`IterMut<'a, T>`][Iterator]size_hint().() |
| 621 | } |
| 622 | } |
| 623 | impl<'a> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for CharsMutrust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut#<'a> { |
| 624 | #[inline] |
| 625 | fn next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`CharsMut<'a>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a mut AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#> { |
| 626 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut#0..next_backrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`IterMut<'a, T>`][DoubleEndedIterator]next_back().() |
| 627 | } |
| 628 | } |
| 629 | impl<'a> ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator# for CharsMutrust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut#<'a> { |
| 630 | fn lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`CharsMut<'a>`][ExactSizeIterator]len().(&self) -> usize { |
| 631 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/CharsMut#0..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`IterMut<'_, T>`][ExactSizeIterator]len().() |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | /// An immutable iterator over the characters of an `AsciiStr`. |
| 636 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 637 | pub struct CharsRefrust-analyzer cargo ascii 1.1.0 ascii_str/CharsRef#<'a>(Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<'a, AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#>); |
| 638 | impl<'a> CharsRefrust-analyzer cargo ascii 1.1.0 ascii_str/CharsRef#<'a> { |
| 639 | /// Returns the ascii string slice with the remaining characters. |
| 640 | #[must_use] |
| 641 | pub fn as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`CharsRef<'a>`]as_str().(&self) -> &'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 642 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/CharsRef#0..as_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`]as_slice().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 643 | } |
| 644 | } |
| 645 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for CharsRefrust-analyzer cargo ascii 1.1.0 ascii_str/CharsRef#<'a> { |
| 646 | type Itemrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`CharsRef<'a>`][Iterator]Item# = &'a AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#; |
| 647 | #[inline] |
| 648 | fn nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`CharsRef<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#> { |
| 649 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/CharsRef#0..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().() |
| 650 | } |
| 651 | fn size_hintrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`CharsRef<'a>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) { |
| 652 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/CharsRef#0..size_hintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]size_hint().() |
| 653 | } |
| 654 | } |
| 655 | impl<'a> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for CharsRefrust-analyzer cargo ascii 1.1.0 ascii_str/CharsRef#<'a> { |
| 656 | #[inline] |
| 657 | fn next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`CharsRef<'a>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#> { |
| 658 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/CharsRef#0..next_backrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][DoubleEndedIterator]next_back().() |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | /// An iterator over parts of an `AsciiStr` separated by an `AsciiChar`. |
| 663 | /// |
| 664 | /// This type is created by [`AsciiChar::split()`](struct.AsciiChar.html#method.split). |
| 665 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 666 | struct Splitrust-analyzer cargo ascii 1.1.0 ascii_str/Split#<'a> { |
| 667 | onrust-analyzer cargo ascii 1.1.0 ascii_str/Split#on.: AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#, |
| 668 | endedrust-analyzer cargo ascii 1.1.0 ascii_str/Split#ended.: bool, |
| 669 | charsrust-analyzer cargo ascii 1.1.0 ascii_str/Split#chars.: Charsrust-analyzer cargo ascii 1.1.0 ascii_str/Chars#<'a>, |
| 670 | } |
| 671 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Splitrust-analyzer cargo ascii 1.1.0 ascii_str/Split#<'a> { |
| 672 | type Itemrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][Iterator]Item# = &'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#; |
| 673 | |
| 674 | fn nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> { |
| 675 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.endedrust-analyzer cargo ascii 1.1.0 ascii_str/Split#ended. { |
| 676 | let start: &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# = self.charsrust-analyzer cargo ascii 1.1.0 ascii_str/Split#chars..as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Chars<'a>`]as_str().(); |
| 677 | let split_on = self.onrust-analyzer cargo ascii 1.1.0 ascii_str/Split#on.; |
| 678 | |
| 679 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(at) = self.charsrust-analyzer cargo ascii 1.1.0 ascii_str/Split#chars..positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#position().(|ch| ch rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq().==rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq(). rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq().split_on) { |
| 680 | // SAFETY: `at` is guaranteed to be in bounds, as `position` returns `Ok(0..len)`. |
| 681 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(unsafe { start.as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().().get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#at).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() }) |
| 682 | } else { |
| 683 | self.endedrust-analyzer cargo ascii 1.1.0 ascii_str/Split#ended. = true; |
| 684 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start) |
| 685 | } |
| 686 | } else { |
| 687 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 688 | } |
| 689 | } |
| 690 | } |
| 691 | impl<'a> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for Splitrust-analyzer cargo ascii 1.1.0 ascii_str/Split#<'a> { |
| 692 | fn next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> { |
| 693 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.endedrust-analyzer cargo ascii 1.1.0 ascii_str/Split#ended. { |
| 694 | let start: &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# = self.charsrust-analyzer cargo ascii 1.1.0 ascii_str/Split#chars..as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Chars<'a>`]as_str().(); |
| 695 | let split_on = self.onrust-analyzer cargo ascii 1.1.0 ascii_str/Split#on.; |
| 696 | |
| 697 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(at) = self.charsrust-analyzer cargo ascii 1.1.0 ascii_str/Split#chars..rpositionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rposition().(|ch| ch rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq().==rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq(). rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq().split_on) { |
| 698 | // SAFETY: `at` is guaranteed to be in bounds, as `rposition` returns `Ok(0..len)`, and slices `1..`, `2..`, etc... until `len..` inclusive, are valid. |
| 699 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(unsafe { start.as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().().get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(at rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() }) |
| 700 | } else { |
| 701 | self.endedrust-analyzer cargo ascii 1.1.0 ascii_str/Split#ended. = true; |
| 702 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(start) |
| 703 | } |
| 704 | } else { |
| 705 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 706 | } |
| 707 | } |
| 708 | } |
| 709 | |
| 710 | /// An iterator over the lines of the internal character array. |
| 711 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 712 | struct Linesrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#<'a> { |
| 713 | stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string.: &'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, |
| 714 | } |
| 715 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Linesrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#<'a> { |
| 716 | type Itemrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Lines<'a>`][Iterator]Item# = &'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#; |
| 717 | |
| 718 | fn nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Lines<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> { |
| 719 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(idx) = self |
| 720 | .stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string. |
| 721 | .charsrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars().() |
| 722 | .positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#position().(|chr| chr rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq().==rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq(). rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq().AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::LineFeedrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#LineFeed#) |
| 723 | { |
| 724 | // SAFETY: `idx` is guaranteed to be `1..len`, as we get it from `position` as `0..len` and make sure it's not `0`. |
| 725 | let line = if idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 |
| 726 | && *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().unsafe { self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().().get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1) } |
| 727 | ==rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq(). rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq().AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::CarriageReturnrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#CarriageReturn# |
| 728 | { |
| 729 | // SAFETY: As per above, `idx` is guaranteed to be `1..len` |
| 730 | unsafe { self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().().get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() } |
| 731 | } else { |
| 732 | // SAFETY: As per above, `idx` is guaranteed to be `0..len` |
| 733 | unsafe { self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().().get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#idx).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() } |
| 734 | }; |
| 735 | // SAFETY: As per above, `idx` is guaranteed to be `0..len`, so at the extreme, slicing `len..` is a valid empty slice. |
| 736 | self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string. = unsafe { self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().().get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() }; |
| 737 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line) |
| 738 | } else if self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..is_emptyrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]is_empty().() { |
| 739 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 740 | } else { |
| 741 | let line = self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string.; |
| 742 | // SAFETY: An empty string is a valid string. |
| 743 | self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string. = unsafe { AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::from_ascii_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii_unchecked().(b"") }; |
| 744 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line) |
| 745 | } |
| 746 | } |
| 747 | } |
| 748 | |
| 749 | impl<'a> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for Linesrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#<'a> { |
| 750 | fn next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Lines<'a>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#> { |
| 751 | if self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..is_emptyrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]is_empty().() { |
| 752 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 753 | } |
| 754 | |
| 755 | // If we end with `LF` / `CR/LF`, remove them |
| 756 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::LineFeedrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#LineFeed#) = self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..lastrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]last().() { |
| 757 | // SAFETY: `last()` returned `Some`, so our len is at least 1. |
| 758 | self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string. = unsafe { |
| 759 | self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string. |
| 760 | .as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().() |
| 761 | .get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1) |
| 762 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 763 | }; |
| 764 | |
| 765 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::CarriageReturnrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#CarriageReturn#) = self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..lastrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]last().() { |
| 766 | // SAFETY: `last()` returned `Some`, so our len is at least 1. |
| 767 | self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string. = unsafe { |
| 768 | self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string. |
| 769 | .as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().() |
| 770 | .get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1) |
| 771 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 772 | }; |
| 773 | } |
| 774 | } |
| 775 | |
| 776 | // Get the position of the first `LF` from the end. |
| 777 | let lf_rev_pos = self |
| 778 | .stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string. |
| 779 | .charsrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars().() |
| 780 | .revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() |
| 781 | .positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#position().(|ch| ch rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq().==rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq(). rust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar][`PartialEq<Self>`]eq().AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::LineFeedrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#LineFeed#) |
| 782 | .unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().()); |
| 783 | |
| 784 | // SAFETY: `lf_rev_pos` will be in range `0..=len`, so `len - lf_rev_pos` |
| 785 | // will be within `0..=len`, making it correct as a start and end |
| 786 | // point for the strings. |
| 787 | let line = unsafe { |
| 788 | self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string. |
| 789 | .as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().() |
| 790 | .get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().lf_rev_pos..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#) |
| 791 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 792 | }; |
| 793 | self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string. = unsafe { |
| 794 | self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string. |
| 795 | .as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().() |
| 796 | .get_uncheckedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_unchecked().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#self.stringrust-analyzer cargo ascii 1.1.0 ascii_str/Lines#string..lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().lf_rev_pos) |
| 797 | .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 798 | }; |
| 799 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(line) |
| 800 | } |
| 801 | } |
| 802 | |
| 803 | /// Error that is returned when a sequence of `u8` are not all ASCII. |
| 804 | /// |
| 805 | /// Is used by `As[Mut]AsciiStr` and the `from_ascii` method on `AsciiStr` and `AsciiString`. |
| 806 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 807 | pub struct AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#(usize); |
| 808 | |
| 809 | const ERRORMSG_STRrust-analyzer cargo ascii 1.1.0 ascii_str/ERRORMSG_STR.: &str = "one or more bytes are not ASCII"; |
| 810 | |
| 811 | impl AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError# { |
| 812 | /// Returns the index of the first non-ASCII byte. |
| 813 | /// |
| 814 | /// It is the maximum index such that `from_ascii(input[..index])` would return `Ok(_)`. |
| 815 | #[inline] |
| 816 | #[must_use] |
| 817 | pub const fn valid_up_torust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsAsciiStrError]valid_up_to().(self) -> usize { |
| 818 | self.0rust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#0. |
| 819 | } |
| 820 | #[cfg(not(feature = "std"))] |
| 821 | /// Returns a description for this error, like `std::error::Error::description`. |
| 822 | #[inline] |
| 823 | #[must_use] |
| 824 | #[allow(clippy::unused_self)] |
| 825 | pub const fn description(&self) -> &'static str { |
| 826 | ERRORMSG_STRrust-analyzer cargo ascii 1.1.0 ascii_str/ERRORMSG_STR. |
| 827 | } |
| 828 | } |
| 829 | impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError# { |
| 830 | fn fmtrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsAsciiStrError][Display]fmt().(&self, fmtr: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 831 | writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(fmtr, "the byte at index {} is not ASCII", self.0rust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#0.) |
| 832 | } |
| 833 | } |
| 834 | #[cfg(feature = "std")] |
| 835 | impl Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError# { |
| 836 | #[inline] |
| 837 | fn descriptionrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsAsciiStrError][Error]description().(&self) -> &'static str { |
| 838 | ERRORMSG_STRrust-analyzer cargo ascii 1.1.0 ascii_str/ERRORMSG_STR. |
| 839 | } |
| 840 | } |
| 841 | |
| 842 | /// Convert slices of bytes or [`AsciiChar`] to [`AsciiStr`]. |
| 843 | // Could nearly replace this trait with SliceIndex, but its methods isn't even |
| 844 | // on a path for stabilization. |
| 845 | pub trait AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# { |
| 846 | /// Used to constrain `SliceIndex` |
| 847 | #[doc(hidden)] |
| 848 | type Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#; |
| 849 | /// Convert a subslice to an ASCII slice. |
| 850 | /// |
| 851 | /// # Errors |
| 852 | /// Returns `Err` if the range is out of bounds or if not all bytes in the |
| 853 | /// slice are ASCII. The value in the error will be the index of the first |
| 854 | /// non-ASCII byte or the end of the slice. |
| 855 | /// |
| 856 | /// # Examples |
| 857 | /// ``` |
| 858 | /// use ascii::AsAsciiStr; |
| 859 | /// assert!("'zoä'".slice_ascii(..3).is_ok()); |
| 860 | /// assert!("'zoä'".slice_ascii(0..4).is_err()); |
| 861 | /// assert!("'zoä'".slice_ascii(5..=5).is_ok()); |
| 862 | /// assert!("'zoä'".slice_ascii(4..).is_err()); |
| 863 | /// assert!(b"\r\n".slice_ascii(..).is_ok()); |
| 864 | /// ``` |
| 865 | fn slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#slice_ascii().<R>(&self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 866 | where |
| 867 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[Self::Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [Self::Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#]>; |
| 868 | /// Convert to an ASCII slice. |
| 869 | /// |
| 870 | /// # Errors |
| 871 | /// Returns `Err` if not all bytes are valid ascii values. |
| 872 | /// |
| 873 | /// # Example |
| 874 | /// ``` |
| 875 | /// use ascii::{AsAsciiStr, AsciiChar}; |
| 876 | /// assert!("ASCII".as_ascii_str().is_ok()); |
| 877 | /// assert!(b"\r\n".as_ascii_str().is_ok()); |
| 878 | /// assert!("'zoä'".as_ascii_str().is_err()); |
| 879 | /// assert!(b"\xff".as_ascii_str().is_err()); |
| 880 | /// assert!([AsciiChar::C][..].as_ascii_str().is_ok()); // infallible |
| 881 | /// ``` |
| 882 | fn as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#as_ascii_str().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> { |
| 883 | self.slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#slice_ascii().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#) |
| 884 | } |
| 885 | /// Get a single ASCII character from the slice. |
| 886 | /// |
| 887 | /// Returns `None` if the index is out of bounds or the byte is not ASCII. |
| 888 | /// |
| 889 | /// # Examples |
| 890 | /// ``` |
| 891 | /// use ascii::{AsAsciiStr, AsciiChar}; |
| 892 | /// assert_eq!("'zoä'".get_ascii(4), None); |
| 893 | /// assert_eq!("'zoä'".get_ascii(5), Some(AsciiChar::Apostrophe)); |
| 894 | /// assert_eq!("'zoä'".get_ascii(6), None); |
| 895 | /// ``` |
| 896 | fn get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#get_ascii().(&self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#> { |
| 897 | self.slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#slice_ascii().(index..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#index) |
| 898 | .okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().() |
| 899 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::firstrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]first().) |
| 900 | } |
| 901 | /// Convert to an ASCII slice without checking for non-ASCII characters. |
| 902 | /// |
| 903 | /// # Safety |
| 904 | /// Calling this function when `self` contains non-ascii characters is |
| 905 | /// undefined behavior. |
| 906 | /// |
| 907 | /// # Examples |
| 908 | /// |
| 909 | unsafe fn as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#as_ascii_str_unchecked().(&self) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#; |
| 910 | } |
| 911 | |
| 912 | /// Convert mutable slices of bytes or [`AsciiChar`] to [`AsciiStr`]. |
| 913 | pub trait AsMutAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr#: AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# { |
| 914 | /// Convert a subslice to an ASCII slice. |
| 915 | /// |
| 916 | /// # Errors |
| 917 | /// This function returns `Err` if range is out of bounds, or if |
| 918 | /// `self` contains non-ascii values |
| 919 | fn slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr#slice_ascii_mut().<R>(&mut self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 920 | where |
| 921 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[Self::Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [Self::Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#]>; |
| 922 | |
| 923 | /// Convert to a mutable ASCII slice. |
| 924 | /// |
| 925 | /// # Errors |
| 926 | /// This function returns `Err` if `self` contains non-ascii values |
| 927 | fn as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr#as_mut_ascii_str().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> { |
| 928 | self.slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr#slice_ascii_mut().(..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#) |
| 929 | } |
| 930 | |
| 931 | /// Convert to a mutable ASCII slice without checking for non-ASCII characters. |
| 932 | /// |
| 933 | /// # Safety |
| 934 | /// Calling this function when `self` contains non-ascii characters is |
| 935 | /// undefined behavior. |
| 936 | unsafe fn as_mut_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr#as_mut_ascii_str_unchecked().(&mut self) -> &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#; |
| 937 | } |
| 938 | |
| 939 | // These generic implementations mirror the generic implementations for AsRef<T> in core. |
| 940 | impl<'a, T> AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# for &'a T |
| 941 | where |
| 942 | T: AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 943 | { |
| 944 | type Innerrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a T`][AsAsciiStr]Inner# = <T as AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#>::Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#; |
| 945 | fn slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a T`][AsAsciiStr]slice_ascii().<R>(&self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 946 | where |
| 947 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a T`][AsAsciiStr]::Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a T`][AsAsciiStr]::Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#]>, |
| 948 | { |
| 949 | <T as AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#>::slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#slice_ascii().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self, range) |
| 950 | } |
| 951 | |
| 952 | unsafe fn as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a T`][AsAsciiStr]as_ascii_str_unchecked().(&self) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 953 | // SAFETY: Caller guarantees `self` does not contain non-ascii characters |
| 954 | unsafe { <T as AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#>::as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#as_ascii_str_unchecked().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self) } |
| 955 | } |
| 956 | } |
| 957 | |
| 958 | impl<'a, T> AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# for &'a mut T |
| 959 | where |
| 960 | T: AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 961 | { |
| 962 | type Innerrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut T`][AsAsciiStr]Inner# = <T as AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#>::Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#; |
| 963 | fn slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut T`][AsAsciiStr]slice_ascii().<R>(&self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 964 | where |
| 965 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut T`][AsAsciiStr]::Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut T`][AsAsciiStr]::Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#]>, |
| 966 | { |
| 967 | <T as AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#>::slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#slice_ascii().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self, range) |
| 968 | } |
| 969 | |
| 970 | unsafe fn as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut T`][AsAsciiStr]as_ascii_str_unchecked().(&self) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 971 | // SAFETY: Caller guarantees `self` does not contain non-ascii characters |
| 972 | unsafe { <T as AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#>::as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#as_ascii_str_unchecked().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self) } |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | impl<'a, T> AsMutAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr# for &'a mut T |
| 977 | where |
| 978 | T: AsMutAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 979 | { |
| 980 | fn slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut T`][AsMutAsciiStr]slice_ascii_mut().<R>(&mut self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 981 | where |
| 982 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut T`][AsMutAsciiStr]::Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [Selfrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut T`][AsMutAsciiStr]::Innerrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#Inner#]>, |
| 983 | { |
| 984 | <T as AsMutAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr#>::slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr#slice_ascii_mut().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self, range) |
| 985 | } |
| 986 | |
| 987 | unsafe fn as_mut_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut T`][AsMutAsciiStr]as_mut_ascii_str_unchecked().(&mut self) -> &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 988 | // SAFETY: Caller guarantees `self` does not contain non-ascii characters |
| 989 | unsafe { <T as AsMutAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr#>::as_mut_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr#as_mut_ascii_str_unchecked().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self) } |
| 990 | } |
| 991 | } |
| 992 | |
| 993 | impl AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 994 | type Innerrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][AsAsciiStr]Inner# = AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#; |
| 995 | |
| 996 | fn slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][AsAsciiStr]slice_ascii().<R>(&self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 997 | where |
| 998 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]>, |
| 999 | { |
| 1000 | self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice..slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][AsAsciiStr]slice_ascii().(range) |
| 1001 | } |
| 1002 | |
| 1003 | #[inline] |
| 1004 | fn as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][AsAsciiStr]as_ascii_str().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> { |
| 1005 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self) |
| 1006 | } |
| 1007 | |
| 1008 | #[inline] |
| 1009 | unsafe fn as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][AsAsciiStr]as_ascii_str_unchecked().(&self) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 1010 | self |
| 1011 | } |
| 1012 | |
| 1013 | #[inline] |
| 1014 | fn get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][AsAsciiStr]get_ascii().(&self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#> { |
| 1015 | self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice..get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][AsAsciiStr]get_ascii().(index) |
| 1016 | } |
| 1017 | } |
| 1018 | impl AsMutAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr# for AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 1019 | fn slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][AsMutAsciiStr]slice_ascii_mut().<R>(&mut self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 1020 | where |
| 1021 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]>, |
| 1022 | { |
| 1023 | self.slicerust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#slice..slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][AsMutAsciiStr]slice_ascii_mut().(range) |
| 1024 | } |
| 1025 | |
| 1026 | #[inline] |
| 1027 | unsafe fn as_mut_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][AsMutAsciiStr]as_mut_ascii_str_unchecked().(&mut self) -> &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 1028 | self |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | impl AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# for [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] { |
| 1033 | type Innerrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][AsAsciiStr]Inner# = AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#; |
| 1034 | fn slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][AsAsciiStr]slice_ascii().<R>(&self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 1035 | where |
| 1036 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]>, |
| 1037 | { |
| 1038 | match self.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(range) { |
| 1039 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(slice) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(slice.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1040 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#(self.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().())), |
| 1041 | } |
| 1042 | } |
| 1043 | |
| 1044 | #[inline] |
| 1045 | fn as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][AsAsciiStr]as_ascii_str().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> { |
| 1046 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 1047 | } |
| 1048 | |
| 1049 | #[inline] |
| 1050 | unsafe fn as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][AsAsciiStr]as_ascii_str_unchecked().(&self) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 1051 | <&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#>::fromrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a AsciiStr`][`From<&'a [AsciiChar]>`]from().(self) |
| 1052 | } |
| 1053 | |
| 1054 | #[inline] |
| 1055 | fn get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][AsAsciiStr]get_ascii().(&self, index: usize) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#> { |
| 1056 | self.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(index).copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]copied().() |
| 1057 | } |
| 1058 | } |
| 1059 | impl AsMutAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr# for [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] { |
| 1060 | fn slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][AsMutAsciiStr]slice_ascii_mut().<R>(&mut self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 1061 | where |
| 1062 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]>, |
| 1063 | { |
| 1064 | let len = self.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(); |
| 1065 | match self.get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_mut().(range) { |
| 1066 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(slice) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(slice.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 1067 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#(len)), |
| 1068 | } |
| 1069 | } |
| 1070 | #[inline] |
| 1071 | unsafe fn as_mut_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][AsMutAsciiStr]as_mut_ascii_str_unchecked().(&mut self) -> &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 1072 | <&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#>::fromrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut AsciiStr`][`From<&'a mut [AsciiChar]>`]from().(self) |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | impl AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# for [u8] { |
| 1077 | type Innerrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]Inner# = u8; |
| 1078 | |
| 1079 | fn slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]slice_ascii().<R>(&self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 1080 | where |
| 1081 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[u8], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [u8]>, |
| 1082 | { |
| 1083 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(slice) = self.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(range) { |
| 1084 | slice.as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#(not_ascii)| { |
| 1085 | let offset = slice.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().() as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().self.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().() as usize; |
| 1086 | AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#(offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().not_ascii) |
| 1087 | }) |
| 1088 | } else { |
| 1089 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#(self.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().())) |
| 1090 | } |
| 1091 | } |
| 1092 | |
| 1093 | fn as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> { |
| 1094 | // is_ascii is likely optimized |
| 1095 | if self.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/ascii/impl#[`[u8]`]is_ascii().() { |
| 1096 | // SAFETY: `is_ascii` guarantees all bytes are within ascii range. |
| 1097 | unsafe { Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str_unchecked().()) } |
| 1098 | } else { |
| 1099 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#( |
| 1100 | self.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(|&b| b.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii().()).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), |
| 1101 | )) |
| 1102 | } |
| 1103 | } |
| 1104 | |
| 1105 | #[inline] |
| 1106 | unsafe fn as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str_unchecked().(&self) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 1107 | // SAFETY: Caller guarantees `self` does not contain non-ascii characters |
| 1108 | unsafe { &*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().(self as *const [u8] as *const AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#) } |
| 1109 | } |
| 1110 | } |
| 1111 | impl AsMutAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr# for [u8] { |
| 1112 | fn slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]slice_ascii_mut().<R>(&mut self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 1113 | where |
| 1114 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[u8], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [u8]>, |
| 1115 | { |
| 1116 | let (ptr, len) = (self.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().(), self.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 1117 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(slice) = self.get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_mut().(range) { |
| 1118 | let slice_ptr = slice.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().(); |
| 1119 | slice |
| 1120 | .as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]as_mut_ascii_str().() |
| 1121 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#(not_ascii)| { |
| 1122 | let offset = slice_ptr as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().ptr as usize; |
| 1123 | AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#(offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().not_ascii) |
| 1124 | }) |
| 1125 | } else { |
| 1126 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#(len)) |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | fn as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]as_mut_ascii_str().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> { |
| 1131 | // is_ascii() is likely optimized |
| 1132 | if self.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/ascii/impl#[`[u8]`]is_ascii().() { |
| 1133 | // SAFETY: `is_ascii` guarantees all bytes are within ascii range. |
| 1134 | unsafe { Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.as_mut_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]as_mut_ascii_str_unchecked().()) } |
| 1135 | } else { |
| 1136 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#( |
| 1137 | self.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(|&b| b.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii().()).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), |
| 1138 | )) |
| 1139 | } |
| 1140 | } |
| 1141 | |
| 1142 | #[inline] |
| 1143 | unsafe fn as_mut_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]as_mut_ascii_str_unchecked().(&mut self) -> &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 1144 | // SAFETY: Caller guarantees `self` does not contain non-ascii characters |
| 1145 | unsafe { &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().(self as *mut [u8] as *mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#) } |
| 1146 | } |
| 1147 | } |
| 1148 | |
| 1149 | impl AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# for str { |
| 1150 | type Innerrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]Inner# = u8; |
| 1151 | fn slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]slice_ascii().<R>(&self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 1152 | where |
| 1153 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[u8], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [u8]>, |
| 1154 | { |
| 1155 | self.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().().slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]slice_ascii().(range) |
| 1156 | } |
| 1157 | fn as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> { |
| 1158 | self.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().().as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str().() |
| 1159 | } |
| 1160 | #[inline] |
| 1161 | unsafe fn as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str_unchecked().(&self) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 1162 | // SAFETY: Caller guarantees `self` does not contain non-ascii characters |
| 1163 | unsafe { self.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().().as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str_unchecked().() } |
| 1164 | } |
| 1165 | } |
| 1166 | impl AsMutAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr# for str { |
| 1167 | fn slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsMutAsciiStr]slice_ascii_mut().<R>(&mut self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 1168 | where |
| 1169 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[u8], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [u8]>, |
| 1170 | { |
| 1171 | // SAFETY: We don't modify the reference in this function, and the caller may |
| 1172 | // only modify it to include valid ascii characters. |
| 1173 | let bytes = unsafe { self.as_bytes_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes_mut().() }; |
| 1174 | match bytes.get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get_mut().(range) { |
| 1175 | // Valid ascii slice |
| 1176 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(slice) if slice.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/ascii/impl#[`[u8]`]is_ascii().() => { |
| 1177 | // SAFETY: All bytes are ascii, so this cast is valid |
| 1178 | let ptr = slice.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().().castrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/mut_ptr/impl#[`*mut T`]cast().::<AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#>(); |
| 1179 | let len = slice.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(); |
| 1180 | |
| 1181 | // SAFETY: The pointer is valid for `len` elements, as it came |
| 1182 | // from a slice. |
| 1183 | unsafe { |
| 1184 | let slice = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/::from_raw_parts_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/raw/from_raw_parts_mut().(ptr, len); |
| 1185 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(<&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#>::fromrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'a mut AsciiStr`][`From<&'a mut [AsciiChar]>`]from().(slice)) |
| 1186 | } |
| 1187 | } |
| 1188 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(slice) => { |
| 1189 | let not_ascii_len = slice.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#copied().().take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(u8::is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii().).countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(); |
| 1190 | let offset = slice.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_ptr().() as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().self.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_ptr().() as usize; |
| 1191 | |
| 1192 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#(offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().not_ascii_len)) |
| 1193 | } |
| 1194 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#(self.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().())), |
| 1195 | } |
| 1196 | } |
| 1197 | fn as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsMutAsciiStr]as_mut_ascii_str().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> { |
| 1198 | match self.bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]bytes().().positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Bytes<'_>`][Iterator]position().(|b| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().b.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii().()) { |
| 1199 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(index) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#(index)), |
| 1200 | // SAFETY: All bytes were iterated, and all were ascii |
| 1201 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => unsafe { Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.as_mut_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsMutAsciiStr]as_mut_ascii_str_unchecked().()) }, |
| 1202 | } |
| 1203 | } |
| 1204 | #[inline] |
| 1205 | unsafe fn as_mut_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsMutAsciiStr]as_mut_ascii_str_unchecked().(&mut self) -> &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 1206 | // SAFETY: Caller guarantees `self` does not contain non-ascii characters |
| 1207 | &mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().(self as *mut str as *mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#) |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | /// Note that the trailing null byte will be removed in the conversion. |
| 1212 | #[cfg(feature = "std")] |
| 1213 | impl AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# for CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr# { |
| 1214 | type Innerrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[CStr][AsAsciiStr]Inner# = u8; |
| 1215 | fn slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[CStr][AsAsciiStr]slice_ascii().<R>(&self, range: R) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> |
| 1216 | where |
| 1217 | R: SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#<[u8], Outputrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#Output# = [u8]>, |
| 1218 | { |
| 1219 | self.to_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/impl#[CStr]to_bytes().().slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]slice_ascii().(range) |
| 1220 | } |
| 1221 | #[inline] |
| 1222 | fn as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[CStr][AsAsciiStr]as_ascii_str().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> { |
| 1223 | self.to_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/impl#[CStr]to_bytes().().as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str().() |
| 1224 | } |
| 1225 | #[inline] |
| 1226 | unsafe fn as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[CStr][AsAsciiStr]as_ascii_str_unchecked().(&self) -> &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# { |
| 1227 | // SAFETY: Caller guarantees `self` does not contain non-ascii characters |
| 1228 | unsafe { self.to_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/impl#[CStr]to_bytes().().as_ascii_str_uncheckedrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str_unchecked().() } |
| 1229 | } |
| 1230 | } |
| 1231 | |
| 1232 | #[cfg(test)] |
| 1233 | mod testsrust-analyzer cargo ascii 1.1.0 ascii_str/tests/ { |
| 1234 | use superrust-analyzer cargo ascii 1.1.0 ascii_str/::{AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#, AsMutAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr#, AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#}; |
| 1235 | #[cfg(feature = "alloc")] |
| 1236 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::{Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, ToStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/ToString#}; |
| 1237 | #[cfg(feature = "alloc")] |
| 1238 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#; |
| 1239 | use AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#; |
| 1240 | |
| 1241 | /// Ensures that common types, `str`, `[u8]`, `AsciiStr` and their |
| 1242 | /// references, shared and mutable implement `AsAsciiStr`. |
| 1243 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1244 | fn generic_as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic_as_ascii_str().() { |
| 1245 | // Generic function to ensure `C` implements `AsAsciiStr` |
| 1246 | fn genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().<C: AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#>(c: &C) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> { |
| 1247 | c.as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#as_ascii_str().() |
| 1248 | } |
| 1249 | |
| 1250 | let arr = [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Arust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#A#]; |
| 1251 | let ascii_str = arr.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsRef<[T]>`]as_ref().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1252 | let mut mut_arr = arr; // Note: We need a second copy to prevent overlapping mutable borrows. |
| 1253 | let mut_ascii_str = mut_arr.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsMut<[T]>`]as_mut().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1254 | let mut_arr_mut_ref: &mut [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] = &mut [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Arust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#A#]; |
| 1255 | let mut string_bytes = [b'A']; |
| 1256 | let string_mut = unsafe { corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/::from_utf8_unchecked_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8_unchecked_mut().(&mut string_bytes) }; // SAFETY: 'A' is a valid string. |
| 1257 | let string_mut_bytes: &mut [u8] = &mut [b'A']; |
| 1258 | |
| 1259 | // Note: This is a trick because `rustfmt` doesn't support |
| 1260 | // attributes on blocks yet. |
| 1261 | #[rustfmt::skip] |
| 1262 | let _ = [ |
| 1263 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().::<str >("A" ), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)), |
| 1264 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().::<[u8] >(&b"A"[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). ), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)), |
| 1265 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().::<AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# >(ascii_str ), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)), |
| 1266 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().::<[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] >(&arr ), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)), |
| 1267 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().::<&str >(&"A" ), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)), |
| 1268 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().::<&[u8] >(&&b"A"[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). ), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)), |
| 1269 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().::<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# >(&ascii_str ), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)), |
| 1270 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().::<&[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#] >(&&arr[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). ), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)), |
| 1271 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().::<&mut str >(&string_mut ), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)), |
| 1272 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().::<&mut [u8] >(&string_mut_bytes), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)), |
| 1273 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().::<&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# >(&mut_ascii_str ), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)), |
| 1274 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().::<&mut [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#]>(&mut_arr_mut_ref ), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)), |
| 1275 | ]; |
| 1276 | } |
| 1277 | |
| 1278 | #[cfg(feature = "std")] |
| 1279 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1280 | fn cstring_as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/cstring_as_ascii_str().() { |
| 1281 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#; |
| 1282 | fn genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().<C: AsAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#>(c: &C) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> { |
| 1283 | c.as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#as_ascii_str().() |
| 1284 | } |
| 1285 | let arr = [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Arust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#A#]; |
| 1286 | let ascii_str: &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# = arr.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsRef<[T]>`]as_ref().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1287 | let cstr = CStringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/CString#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString]new().("A").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1288 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(genericrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc ffi/c_str/impl#[CString][Deref]deref().cstr), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ascii_str)); |
| 1289 | } |
| 1290 | |
| 1291 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1292 | fn generic_as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic_as_mut_ascii_str().() { |
| 1293 | fn generic_mutrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic_mut().<C: AsMutAsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr# + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#>( |
| 1294 | c: &mut C, |
| 1295 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#, AsAsciiStrErrorrust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStrError#> { |
| 1296 | c.as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/AsMutAsciiStr#as_mut_ascii_str().() |
| 1297 | } |
| 1298 | |
| 1299 | let mut arr_mut = [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Brust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#B#]; |
| 1300 | let mut ascii_str_mut: &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# = arr_mut.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsMut<[T]>`]as_mut().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1301 | // Need a second reference to prevent overlapping mutable borrows |
| 1302 | let mut arr_mut_2 = [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Brust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#B#]; |
| 1303 | let ascii_str_mut_2: &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# = arr_mut_2.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsMut<[T]>`]as_mut().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1304 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(generic_mutrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic_mut().(&mut ascii_str_mut), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().ascii_str_mut_2)); |
| 1305 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(generic_mutrust-analyzer cargo ascii 1.1.0 ascii_str/tests/generic_mut().(ascii_str_mut), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&mut *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().ascii_str_mut_2)); |
| 1306 | } |
| 1307 | |
| 1308 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1309 | fn as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/as_ascii_str().() { |
| 1310 | macro_rules! errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err! {{$i:expr} => {Err(AsAsciiStrError($i))}} |
| 1311 | let s = "abčd"; |
| 1312 | let b = s.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().(); |
| 1313 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s.as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().(), errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err!!(2)); |
| 1314 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str().(), errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err!!(2)); |
| 1315 | let a: &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# = [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::arust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#a#, AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::brust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#b#][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()..as_refrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][`AsRef<AsciiStr>`]as_ref().(); |
| 1316 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(a)); |
| 1317 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(a)); |
| 1318 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s.slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]slice_ascii().(..2), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(a)); |
| 1319 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]slice_ascii().(..2), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(a)); |
| 1320 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s.slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]slice_ascii().(..=2), errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err!!(2)); |
| 1321 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]slice_ascii().(..=2), errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err!!(2)); |
| 1322 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s.get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#get_ascii().(4), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::drust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#d#)); |
| 1323 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#get_ascii().(4), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::drust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#d#)); |
| 1324 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s.get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#get_ascii().(3), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1325 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#get_ascii().(3), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1326 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s.get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#get_ascii().(b.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1327 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#get_ascii().(b.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1328 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][AsAsciiStr]get_ascii().(0), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::arust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#a#)); |
| 1329 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][AsAsciiStr]get_ascii().(a.lenrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]len().()), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1330 | } |
| 1331 | |
| 1332 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1333 | #[cfg(feature = "std")] |
| 1334 | fn cstr_as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/cstr_as_ascii_str().() { |
| 1335 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#; |
| 1336 | macro_rules! errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err! {{$i:expr} => {Err(AsAsciiStrError($i))}} |
| 1337 | let cstr = CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#::from_bytes_with_nulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/impl#[CStr]from_bytes_with_nul().(b"a\xbbcde\xffg\0").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1338 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cstr.as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[CStr][AsAsciiStr]as_ascii_str().(), errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err!!(1)); |
| 1339 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cstr.slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[CStr][AsAsciiStr]slice_ascii().(2..), errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err!!(5)); |
| 1340 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cstr.get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#get_ascii().(5), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1341 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cstr.get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#get_ascii().(6), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::grust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#g#)); |
| 1342 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cstr.get_asciirust-analyzer cargo ascii 1.1.0 ascii_str/AsAsciiStr#get_ascii().(7), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1343 | let ascii_slice = &[AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Xrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#X#, AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Yrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#Y#, AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Zrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#Z#, AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Nullrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#Null#][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().; |
| 1344 | let ascii_str: &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# = ascii_slice.as_refrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[AsciiChar]`][`AsRef<AsciiStr>`]as_ref().(); |
| 1345 | let cstr = CStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/CStr#::from_bytes_with_nulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ffi/c_str/impl#[CStr]from_bytes_with_nul().(ascii_str.as_bytesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_bytes().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1346 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cstr.slice_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[CStr][AsAsciiStr]slice_ascii().(..2), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&ascii_str[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)); |
| 1347 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cstr.as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[CStr][AsAsciiStr]as_ascii_str().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(&ascii_str[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)); |
| 1348 | } |
| 1349 | |
| 1350 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1351 | #[cfg(feature = "alloc")] |
| 1352 | fn as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/as_mut_ascii_str().() { |
| 1353 | macro_rules! errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err! {{$i:expr} => {Err(AsAsciiStrError($i))}} |
| 1354 | let mut s: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# = "abčd".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 1355 | let mut b: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> = s.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1356 | let mut first = [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::arust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#a#, AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::brust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#b#]; |
| 1357 | let mut second = [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::drust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#d#]; |
| 1358 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s.as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsMutAsciiStr]as_mut_ascii_str().(), errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err!!(2)); |
| 1359 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]as_mut_ascii_str().(), errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err!!(2)); |
| 1360 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s.slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsMutAsciiStr]slice_ascii_mut().(..), errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err!!(2)); |
| 1361 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]slice_ascii_mut().(..), errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err!!(2)); |
| 1362 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`IndexMut<I>`]index_mut()...2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`IndexMut<I>`]index_mut()..as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsMutAsciiStr]as_mut_ascii_str().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((&mut first[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 1363 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut()...2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut()..as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]as_mut_ascii_str().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((&mut first[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 1364 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s.slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsMutAsciiStr]slice_ascii_mut().(0..2), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((&mut first[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 1365 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]slice_ascii_mut().(0..2), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((&mut first[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 1366 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s.slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsMutAsciiStr]slice_ascii_mut().(4..), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((&mut second[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 1367 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]slice_ascii_mut().(4..), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((&mut second[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())); |
| 1368 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s.slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsMutAsciiStr]slice_ascii_mut().(4..=10), errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err!!(5)); |
| 1369 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.slice_ascii_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]slice_ascii_mut().(4..=10), errrust-analyzer cargo ascii 1.1.0 ascii_str/tests/err!!(5)); |
| 1370 | } |
| 1371 | |
| 1372 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1373 | fn defaultrust-analyzer cargo ascii 1.1.0 ascii_str/tests/default().() { |
| 1374 | let default: &'static AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# = Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'static AsciiStr`][Default]default().(); |
| 1375 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(default.is_emptyrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]is_empty().()); |
| 1376 | } |
| 1377 | |
| 1378 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1379 | #[allow(clippy::redundant_slicing)] |
| 1380 | fn indexrust-analyzer cargo ascii 1.1.0 ascii_str/tests/index().() { |
| 1381 | let mut arr = [AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Arust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#A#, AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Brust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#B#, AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Crust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#C#, AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Drust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#D#]; |
| 1382 | { |
| 1383 | let a: &AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# = arr[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1384 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().(), &a.as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 1385 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().(), &a.as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 1386 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().4..]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().(), &a.as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().4..]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 1387 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2..3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().(), &a.as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2..3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 1388 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...=3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().(), &a.as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...=3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 1389 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..=1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().(), &a.as_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_slice().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..=1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 1390 | } |
| 1391 | let mut copy = arr; |
| 1392 | let a_mut: &mut AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr# = { &mut arr[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). }.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 1393 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a_mut[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..as_mut_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_mut_slice().(), &mut copy[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()...]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().); |
| 1394 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a_mut[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()...2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..as_mut_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_mut_slice().(), &mut copy[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()...2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().); |
| 1395 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a_mut[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().3..]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..as_mut_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_mut_slice().(), &mut copy[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().3..]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().); |
| 1396 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a_mut[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().4..4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..as_mut_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_mut_slice().(), &mut copy[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().4..4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().); |
| 1397 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a_mut[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()...=0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..as_mut_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_mut_slice().(), &mut copy[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()...=0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().); |
| 1398 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a_mut[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0..=2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut()..as_mut_slicerust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_mut_slice().(), &mut copy[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0..=2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().); |
| 1399 | } |
| 1400 | |
| 1401 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1402 | fn as_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/as_str().() { |
| 1403 | let b = b"( ;"; |
| 1404 | let v = AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::from_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii().(b).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1405 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_str().(), "( ;"); |
| 1406 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#::<str>::as_refrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][`AsRef<str>`]as_ref().(v), "( ;"); |
| 1407 | } |
| 1408 | |
| 1409 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1410 | fn as_bytesrust-analyzer cargo ascii 1.1.0 ascii_str/tests/as_bytes().() { |
| 1411 | let b = b"( ;"; |
| 1412 | let v = AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::from_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii().(b).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1413 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.as_bytesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_bytes().(), b"( ;"); |
| 1414 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#::<[u8]>::as_refrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr][`AsRef<[u8]>`]as_ref().(v), b"( ;"); |
| 1415 | } |
| 1416 | |
| 1417 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1418 | fn make_ascii_caserust-analyzer cargo ascii 1.1.0 ascii_str/tests/make_ascii_case().() { |
| 1419 | let mut bytes = ([b'a', b'@', b'A'], [b'A', b'@', b'a']); |
| 1420 | let a = bytes.0.as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]as_mut_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1421 | let b = bytes.1.as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]as_mut_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1422 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(a.eq_ignore_ascii_caserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]eq_ignore_ascii_case().(b)); |
| 1423 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(b.eq_ignore_ascii_caserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]eq_ignore_ascii_case().(a)); |
| 1424 | a.make_ascii_lowercaserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]make_ascii_lowercase().(); |
| 1425 | b.make_ascii_uppercaserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]make_ascii_uppercase().(); |
| 1426 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a, "a@a"); |
| 1427 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b, "A@A"); |
| 1428 | } |
| 1429 | |
| 1430 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1431 | #[cfg(feature = "alloc")] |
| 1432 | fn to_ascii_caserust-analyzer cargo ascii 1.1.0 ascii_str/tests/to_ascii_case().() { |
| 1433 | let bytes = ([b'a', b'@', b'A'], [b'A', b'@', b'a']); |
| 1434 | let a = bytes.0.as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1435 | let b = bytes.1.as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1436 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.to_ascii_lowercaserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]to_ascii_lowercase().().as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_str().(), "a@a"); |
| 1437 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.to_ascii_uppercaserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]to_ascii_uppercase().().as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_str().(), "A@A"); |
| 1438 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.to_ascii_lowercaserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]to_ascii_lowercase().().as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_str().(), "a@a"); |
| 1439 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b.to_ascii_uppercaserust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]to_ascii_uppercase().().as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_str().(), "A@A"); |
| 1440 | } |
| 1441 | |
| 1442 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1443 | fn chars_iterrust-analyzer cargo ascii 1.1.0 ascii_str/tests/chars_iter().() { |
| 1444 | let chars = &[ |
| 1445 | b'h', b'e', b'l', b'l', b'o', b' ', b'w', b'o', b'r', b'l', b'd', b'\0', |
| 1446 | ]; |
| 1447 | let ascii = AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::from_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii().(chars).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1448 | for (achar, byte) in ascii.charsrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(chars.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().copiedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#copied().()) { |
| 1449 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(achar, byte); |
| 1450 | } |
| 1451 | } |
| 1452 | |
| 1453 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1454 | fn chars_iter_mutrust-analyzer cargo ascii 1.1.0 ascii_str/tests/chars_iter_mut().() { |
| 1455 | let chars = &mut [ |
| 1456 | b'h', b'e', b'l', b'l', b'o', b' ', b'w', b'o', b'r', b'l', b'd', b'\0', |
| 1457 | ]; |
| 1458 | let ascii = chars.as_mut_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`[u8]`][AsMutAsciiStr]as_mut_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1459 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().ascii.chars_mutrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]chars_mut().().nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`CharsMut<'a>`][Iterator]next().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() = AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Hrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#H#; |
| 1460 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ascii[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., b'H'); |
| 1461 | } |
| 1462 | |
| 1463 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1464 | fn lines_iterrust-analyzer cargo ascii 1.1.0 ascii_str/tests/lines_iter().() { |
| 1465 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#; |
| 1466 | |
| 1467 | let lines: [&str; 4] = ["foo", "bar", "", "baz"]; |
| 1468 | let joined = "foo\r\nbar\n\nbaz\n"; |
| 1469 | let ascii = AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::from_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii().(joined.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1470 | for (asciiline, line) in ascii.linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(&lines) { |
| 1471 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(asciiline, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().line); |
| 1472 | } |
| 1473 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ascii.linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), lines.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 1474 | |
| 1475 | let lines: [&str; 4] = ["foo", "bar", "", "baz"]; |
| 1476 | let joined = "foo\r\nbar\n\nbaz"; |
| 1477 | let ascii = AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::from_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii().(joined.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1478 | for (asciiline, line) in ascii.linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(&lines) { |
| 1479 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(asciiline, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().line); |
| 1480 | } |
| 1481 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ascii.linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), lines.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 1482 | |
| 1483 | let trailing_line_break = b"\n"; |
| 1484 | let ascii = AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::from_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii().(&trailing_line_break).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1485 | let mut line_iter = ascii.linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().(); |
| 1486 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(line_iter.nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Lines<'a>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::from_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii().("").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())); |
| 1487 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(line_iter.nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Lines<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1488 | |
| 1489 | let empty_lines = b"\n\r\n\n\r\n"; |
| 1490 | let mut iter_count = 0; |
| 1491 | let ascii = AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::from_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii().(&empty_lines).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1492 | for line in ascii.linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().() { |
| 1493 | iter_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().1; |
| 1494 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(line.is_emptyrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]is_empty().()); |
| 1495 | } |
| 1496 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(4, iter_count); |
| 1497 | } |
| 1498 | |
| 1499 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1500 | fn lines_iter_revrust-analyzer cargo ascii 1.1.0 ascii_str/tests/lines_iter_rev().() { |
| 1501 | let joined = "foo\r\nbar\n\nbaz\n"; |
| 1502 | let ascii = AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::from_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii().(joined.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1503 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ascii.linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 4); |
| 1504 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ascii.linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), joined.linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().()); |
| 1505 | for (asciiline, line) in ascii.linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(joined.linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().()) { |
| 1506 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(asciiline, line); |
| 1507 | } |
| 1508 | let mut iter = ascii.linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().(); |
| 1509 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Lines<'a>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())); |
| 1510 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Lines<'a>`][DoubleEndedIterator]next_back().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("baz".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())); |
| 1511 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Lines<'a>`][DoubleEndedIterator]next_back().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())); |
| 1512 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Lines<'a>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("bar".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())); |
| 1513 | |
| 1514 | let empty_lines = b"\n\r\n\n\r\n"; |
| 1515 | let mut iter_count = 0; |
| 1516 | let ascii = AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::from_asciirust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]from_ascii().(&empty_lines).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1517 | for line in ascii.linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() { |
| 1518 | iter_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`AddAssign<Self>`]add_assign().1; |
| 1519 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(line.is_emptyrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]is_empty().()); |
| 1520 | } |
| 1521 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(4, iter_count); |
| 1522 | } |
| 1523 | |
| 1524 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1525 | fn lines_iter_emptyrust-analyzer cargo ascii 1.1.0 ascii_str/tests/lines_iter_empty().() { |
| 1526 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().().nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Lines<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1527 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().linesrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]lines().().next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Lines<'a>`][DoubleEndedIterator]next_back().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1528 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("".linesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]lines().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Lines<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1529 | } |
| 1530 | |
| 1531 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1532 | fn split_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/split_str().() { |
| 1533 | fn split_equals_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/split_equals_str().(haystack: &str, needle: char) { |
| 1534 | let mut strs = haystack.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(needle); |
| 1535 | let mut asciis = haystack |
| 1536 | .as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().() |
| 1537 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 1538 | .splitrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]split().(AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::from_asciirust-analyzer cargo ascii 1.1.0 ascii_char/impl#[AsciiChar]from_ascii().(needle).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()) |
| 1539 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#::as_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]as_str().); |
| 1540 | loop { |
| 1541 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(asciis.size_hintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]size_hint().(), strs.size_hintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#size_hint().()); |
| 1542 | let (a, s) = (asciis.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().(), strs.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().()); |
| 1543 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a, s); |
| 1544 | if a rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# { |
| 1545 | break; |
| 1546 | } |
| 1547 | } |
| 1548 | // test fusedness if str's version is fused |
| 1549 | if strs.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][`PartialEq<Self>`]eq().Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# { |
| 1550 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(asciis.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/map/impl#[`Map<I, F>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1551 | } |
| 1552 | } |
| 1553 | split_equals_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/split_equals_str().("", '='); |
| 1554 | split_equals_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/split_equals_str().("1,2,3", ','); |
| 1555 | split_equals_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/split_equals_str().("foo;bar;baz;", ';'); |
| 1556 | split_equals_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/split_equals_str().("|||", '|'); |
| 1557 | split_equals_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/split_equals_str().(" a b c ", ' '); |
| 1558 | } |
| 1559 | |
| 1560 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1561 | fn split_str_revrust-analyzer cargo ascii 1.1.0 ascii_str/tests/split_str_rev().() { |
| 1562 | let words = " foo bar baz "; |
| 1563 | let ascii = words.as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1564 | for (word, asciiword) in words |
| 1565 | .splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(' ') |
| 1566 | .revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() |
| 1567 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(ascii.splitrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]split().(AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Spacerust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#Space#).revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().()) |
| 1568 | { |
| 1569 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(asciiword, word); |
| 1570 | } |
| 1571 | let mut iter = ascii.splitrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]split().(AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::Spacerust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#Space#); |
| 1572 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())); |
| 1573 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][DoubleEndedIterator]next_back().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())); |
| 1574 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("foo".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())); |
| 1575 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][DoubleEndedIterator]next_back().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("baz".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())); |
| 1576 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][DoubleEndedIterator]next_back().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("bar".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())); |
| 1577 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())); |
| 1578 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][DoubleEndedIterator]next_back().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1579 | } |
| 1580 | |
| 1581 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1582 | fn split_str_emptyrust-analyzer cargo ascii 1.1.0 ascii_str/tests/split_str_empty().() { |
| 1583 | let empty = <&AsciiStrrust-analyzer cargo ascii 1.1.0 ascii_str/AsciiStr#>::defaultrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`&'static AsciiStr`][Default]default().(); |
| 1584 | let mut iter = empty.splitrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]split().(AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::NAKrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#NAK#); |
| 1585 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(empty)); |
| 1586 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.nextrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][Iterator]next().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1587 | let mut iter = empty.splitrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[AsciiStr]split().(AsciiCharrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#::NAKrust-analyzer cargo ascii 1.1.0 ascii_char/AsciiChar#NAK#); |
| 1588 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][DoubleEndedIterator]next_back().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(empty)); |
| 1589 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(iter.next_backrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[`Split<'a>`][DoubleEndedIterator]next_back().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1590 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("".splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().('s').nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("")); // str.split() also produces one element |
| 1591 | } |
| 1592 | |
| 1593 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1594 | #[cfg(feature = "std")] |
| 1595 | fn fmt_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/tests/fmt_ascii_str().() { |
| 1596 | let s = "abc".as_ascii_strrust-analyzer cargo ascii 1.1.0 ascii_str/impl#[str][AsAsciiStr]as_ascii_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 1597 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", s), "abc".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 1598 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:?}", s), "\"abc\"".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()); |
| 1599 | } |
| 1600 | } |