| 1 | //! Percent-encoding utilities. |
| 2 | |
| 3 | pub mod encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/encoder/; |
| 4 | #[cfg(feature = "alloc")] |
| 5 | mod estringrust-analyzer cargo fluent-uri 0.4.1 pct_enc/estring/; |
| 6 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) mod tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/; |
| 7 | |
| 8 | #[cfg(feature = "alloc")] |
| 9 | pub use estringrust-analyzer cargo fluent-uri 0.4.1 pct_enc/estring/::EStringrust-analyzer cargo fluent-uri 0.4.1 pct_enc/estring/EString#; |
| 10 | pub use tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/::Tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/Table#; |
| 11 | |
| 12 | use craterust-analyzer cargo fluent-uri 0.4.1 crate/::imprust-analyzer cargo fluent-uri 0.4.1 imp/::PathEncoderrust-analyzer cargo fluent-uri 0.4.1 imp/PathEncoder#; |
| 13 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#, hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/, iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator#, markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/}; |
| 14 | use ref_castrust-analyzer cargo ref-cast 1.0.25 crate/::{ref_cast_customrust-analyzer cargo ref-cast-impl 1.0.25 ref_cast_custom:, RefCastCustomrust-analyzer cargo ref-cast-impl 1.0.25 RefCastCustom:}; |
| 15 | |
| 16 | #[cfg(feature = "alloc")] |
| 17 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::{ |
| 18 | borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::{Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#, ToOwnedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/ToOwned#}, |
| 19 | 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#, |
| 20 | 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#, |
| 21 | }; |
| 22 | |
| 23 | /// A trait used by [`EStr`] and [`EString`] to specify the table used for encoding. |
| 24 | /// |
| 25 | /// # Sub-encoders |
| 26 | /// |
| 27 | /// A sub-encoder `SubE` of `E` is an encoder such that `SubE::TABLE` is a [subset] of `E::TABLE`. |
| 28 | /// |
| 29 | /// [subset]: Table::is_subset |
| 30 | pub trait Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#: 'static { |
| 31 | /// The table used for encoding. |
| 32 | const TABLErust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#TABLE.: &'static Tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/Table#; |
| 33 | } |
| 34 | |
| 35 | /// Percent-encoded string slices. |
| 36 | /// |
| 37 | /// The owned counterpart of `EStr` is [`EString`]. See its documentation |
| 38 | /// if you want to build a percent-encoded string from scratch. |
| 39 | /// |
| 40 | /// # Type parameter |
| 41 | /// |
| 42 | /// The `EStr<E>` type is parameterized over a type `E` that implements [`Encoder`]. |
| 43 | /// The associated constant `E::TABLE` of type [`Table`] specifies the byte patterns |
| 44 | /// allowed in a string. In short, the underlying byte sequence of an `EStr<E>` slice |
| 45 | /// can be formed by joining any number of the following byte sequences: |
| 46 | /// |
| 47 | /// - `ch.encode_utf8(&mut [0; 4])` where `E::TABLE.allows(ch)`. |
| 48 | /// - `[b'%', hi, lo]` where `E::TABLE.allows_pct_encoded() && hi.is_ascii_hexdigit() && lo.is_ascii_hexdigit()`. |
| 49 | /// |
| 50 | /// # Comparison |
| 51 | /// |
| 52 | /// `EStr` slices are compared [lexicographically](Ord#lexicographical-comparison) |
| 53 | /// by their byte values. Normalization is **not** performed prior to comparison. |
| 54 | /// |
| 55 | /// # Examples |
| 56 | /// |
| 57 | /// Parse key-value pairs from a query string into a hash map: |
| 58 | /// |
| 59 | /// ``` |
| 60 | /// use fluent_uri::{pct_enc::EStr, UriRef}; |
| 61 | /// use std::collections::HashMap; |
| 62 | /// |
| 63 | /// let s = "?name=%E5%BC%A0%E4%B8%89&speech=%C2%A1Ol%C3%A9%21"; |
| 64 | /// let query = UriRef::parse(s)?.query().unwrap(); |
| 65 | /// let map: HashMap<_, _> = query |
| 66 | /// .split('&') |
| 67 | /// .map(|s| s.split_once('=').unwrap_or((s, EStr::EMPTY))) |
| 68 | /// .map(|(k, v)| (k.decode().to_string_lossy(), v.decode().to_string_lossy())) |
| 69 | /// .collect(); |
| 70 | /// assert_eq!(map["name"], "张三"); |
| 71 | /// assert_eq!(map["speech"], "¡Olé!"); |
| 72 | /// # Ok::<_, fluent_uri::ParseError>(()) |
| 73 | /// ``` |
| 74 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(RefCastCustomrust-analyzer cargo ref-cast-impl 1.0.25 RefCastCustom:)] |
| 75 | #[repr(transparent)] |
| 76 | pub struct EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> { |
| 77 | encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#encoder.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<E>, |
| 78 | innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner.: str, |
| 79 | } |
| 80 | |
| 81 | #[cfg(feature = "alloc")] |
| 82 | struct Assertrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Assert#<L: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#, R: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> { |
| 83 | _markerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Assert#_marker.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<(L, R)>, |
| 84 | } |
| 85 | |
| 86 | #[cfg(feature = "alloc")] |
| 87 | impl<L: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#, R: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> Assertrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Assert#<L, R> { |
| 88 | const L_IS_SUB_ENCODER_OF_Rrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Assert<L, R>`]L_IS_SUB_ENCODER_OF_R.: () = assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(L::TABLErust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#TABLE..is_subsetrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]is_subset().(R::TABLErust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#TABLE.), "not a sub-encoder"); |
| 89 | } |
| 90 | |
| 91 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E> { |
| 92 | const ASSERT_ALLOWS_PCT_ENCODEDrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]ASSERT_ALLOWS_PCT_ENCODED.: () = assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 93 | E::TABLErust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#TABLE..allows_pct_encodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]allows_pct_encoded().(), |
| 94 | "table does not allow percent-encoded octets" |
| 95 | ); |
| 96 | |
| 97 | /// Converts a string slice to an `EStr` slice assuming validity. |
| 98 | #[ref_cast_customrust-analyzer cargo ref-cast-impl 1.0.25 ref_cast_custom:] |
| 99 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) const fn new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_validated().(s: &str) -> &Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]; |
| 100 | |
| 101 | /// An empty `EStr` slice. |
| 102 | pub const EMPTYrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]EMPTY.: &'static Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`] = Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]::new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_validated().(""); |
| 103 | |
| 104 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) fn castrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]cast().<F: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#>(&self) -> &EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<F> { |
| 105 | EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#::new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_validated().(&self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner.) |
| 106 | } |
| 107 | |
| 108 | /// Converts a string slice to an `EStr` slice. |
| 109 | /// |
| 110 | /// # Panics |
| 111 | /// |
| 112 | /// Panics if the string is not properly encoded with `E`. |
| 113 | /// For a non-panicking variant, use [`new`](Self::new). |
| 114 | #[must_use] |
| 115 | pub const fn new_or_panicrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_or_panic().(s: &str) -> &Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`] { |
| 116 | match Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]::newrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new().(s) { |
| 117 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) => s, |
| 118 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => panicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/panic!!("improperly encoded string"), |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | /// Converts a string slice to an `EStr` slice, returning `None` if the conversion fails. |
| 123 | #[must_use] |
| 124 | pub const fn newrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new().(s: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]> { |
| 125 | if E::TABLErust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#TABLE..validaterust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]validate().(s.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()) { |
| 126 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]::new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_validated().(s)) |
| 127 | } else { |
| 128 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | /// Creates an `EStr` slice containing a single percent-encoded octet representing the given byte. |
| 133 | /// |
| 134 | /// # Panics |
| 135 | /// |
| 136 | /// Panics at compile time if `E::TABLE` does not [allow percent-encoded octets]. |
| 137 | /// |
| 138 | /// [allow percent-encoded octets]: Table::allows_pct_encoded |
| 139 | /// |
| 140 | /// # Examples |
| 141 | /// |
| 142 | /// ``` |
| 143 | /// use fluent_uri::pct_enc::{encoder::Path, EStr}; |
| 144 | /// |
| 145 | /// assert_eq!(EStr::<Path>::encode_byte(b'1'), "%31"); |
| 146 | /// ``` |
| 147 | #[must_use] |
| 148 | pub fn encode_byterust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]encode_byte().(x: u8) -> &'static Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`] { |
| 149 | () = Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]::ASSERT_ALLOWS_PCT_ENCODEDrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]ASSERT_ALLOWS_PCT_ENCODED.; |
| 150 | Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]::new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_validated().(encode_byterust-analyzer cargo fluent-uri 0.4.1 pct_enc/encode_byte().(x)) |
| 151 | } |
| 152 | |
| 153 | /// Yields the underlying string slice. |
| 154 | #[must_use] |
| 155 | pub fn as_strrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]as_str().(&self) -> &str { |
| 156 | &self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner. |
| 157 | } |
| 158 | |
| 159 | /// Returns the length of the `EStr` slice in bytes. |
| 160 | #[must_use] |
| 161 | pub fn lenrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]len().(&self) -> usize { |
| 162 | self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() |
| 163 | } |
| 164 | |
| 165 | /// Checks whether the `EStr` slice is empty. |
| 166 | #[must_use] |
| 167 | pub fn is_emptyrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]is_empty().(&self) -> bool { |
| 168 | self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() |
| 169 | } |
| 170 | |
| 171 | /// Upcasts the `EStr` slice to associate it with the given super-encoder. |
| 172 | /// |
| 173 | /// # Panics |
| 174 | /// |
| 175 | /// Panics at compile time if `E` is not a [sub-encoder](Encoder#sub-encoders) of `SuperE`. |
| 176 | /// |
| 177 | /// # Example |
| 178 | /// |
| 179 | /// ``` |
| 180 | /// use fluent_uri::pct_enc::{encoder::{IPath, Path}, EStr}; |
| 181 | /// |
| 182 | /// let path = EStr::<Path>::new_or_panic("foo"); |
| 183 | /// let path: &EStr<IPath> = path.upcast(); |
| 184 | /// ``` |
| 185 | #[cfg(fluent_uri_unstable)] |
| 186 | #[must_use] |
| 187 | pub fn upcast<SuperE: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#>(&self) -> &EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<SuperE> { |
| 188 | () = Assertrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Assert#::<E, SuperE>::L_IS_SUB_ENCODER_OF_R; |
| 189 | EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#::new_validated(selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/.as_str()) |
| 190 | } |
| 191 | |
| 192 | /// Checks whether the `EStr` slice is unencoded, i.e., does not contain `'%'`. |
| 193 | /// |
| 194 | /// # Examples |
| 195 | /// |
| 196 | /// ``` |
| 197 | /// use fluent_uri::pct_enc::{encoder::Path, EStr}; |
| 198 | /// |
| 199 | /// assert!(EStr::<Path>::new_or_panic("Hello!").is_unencoded()); |
| 200 | /// assert!(!EStr::<Path>::new_or_panic("%C2%A1Hola%21").is_unencoded()); |
| 201 | /// ``` |
| 202 | #[cfg(fluent_uri_unstable)] |
| 203 | #[must_use] |
| 204 | pub fn is_unencoded(&self) -> bool { |
| 205 | !(E::TABLE.allows_pct_encoded() && selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/.inner.contains('%')) |
| 206 | } |
| 207 | |
| 208 | /// Returns an iterator used to decode the `EStr` slice. |
| 209 | /// |
| 210 | /// Always **split before decoding**, as otherwise the data may be |
| 211 | /// mistaken for component delimiters. |
| 212 | /// |
| 213 | /// Note that the iterator will **not** decode `U+002B` (+) as `0x20` (space). |
| 214 | /// |
| 215 | /// # Panics |
| 216 | /// |
| 217 | /// Panics at compile time if `E::TABLE` does not [allow percent-encoded octets]. |
| 218 | /// |
| 219 | /// [allow percent-encoded octets]: Table::allows_pct_encoded |
| 220 | /// |
| 221 | /// # Examples |
| 222 | /// |
| 223 | /// ``` |
| 224 | /// use fluent_uri::pct_enc::{encoder::Path, EStr}; |
| 225 | /// |
| 226 | /// let dec = EStr::<Path>::new_or_panic("%C2%A1Hola%21").decode(); |
| 227 | /// assert_eq!(*dec.clone().to_bytes(), [0xc2, 0xa1, 0x48, 0x6f, 0x6c, 0x61, 0x21]); |
| 228 | /// assert_eq!(dec.to_string().unwrap(), "¡Hola!"); |
| 229 | /// ``` |
| 230 | pub fn decoderust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]decode().(&self) -> Decoderust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#<'_> { |
| 231 | () = Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]::ASSERT_ALLOWS_PCT_ENCODEDrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]ASSERT_ALLOWS_PCT_ENCODED.; |
| 232 | Decoderust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#::newrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]new().(&self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner.) |
| 233 | } |
| 234 | |
| 235 | /// Returns an iterator over subslices of the `EStr` slice separated by the given delimiter. |
| 236 | /// |
| 237 | /// # Panics |
| 238 | /// |
| 239 | /// Panics if the delimiter is not a [reserved] character. |
| 240 | /// |
| 241 | /// [reserved]: https://datatracker.ietf.org/doc/html/rfc3986#section-2.2 |
| 242 | /// |
| 243 | /// # Examples |
| 244 | /// |
| 245 | /// ``` |
| 246 | /// use fluent_uri::pct_enc::{encoder::Path, EStr}; |
| 247 | /// |
| 248 | /// assert!(EStr::<Path>::new_or_panic("a,b,c").split(',').eq(["a", "b", "c"])); |
| 249 | /// assert!(EStr::<Path>::new_or_panic(",").split(',').eq(["", ""])); |
| 250 | /// assert!(EStr::<Path>::EMPTY.split(',').eq([""])); |
| 251 | /// ``` |
| 252 | pub fn splitrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]split().(&self, delim: char) -> Splitrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split#<'_, E> { |
| 253 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 254 | delim.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_ascii().() && tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/::RESERVEDrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/RESERVED..allowsrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]allows().(delim), |
| 255 | "splitting with non-reserved character" |
| 256 | ); |
| 257 | Splitrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split# { |
| 258 | innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split#inner.: self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner..splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().(delim), |
| 259 | encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split#encoder.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | /// Splits the `EStr` slice on the first occurrence of the given delimiter and |
| 264 | /// returns prefix before delimiter and suffix after delimiter. |
| 265 | /// |
| 266 | /// Returns `None` if the delimiter is not found. |
| 267 | /// |
| 268 | /// # Panics |
| 269 | /// |
| 270 | /// Panics if the delimiter is not a [reserved] character. |
| 271 | /// |
| 272 | /// [reserved]: https://datatracker.ietf.org/doc/html/rfc3986#section-2.2 |
| 273 | /// |
| 274 | /// # Examples |
| 275 | /// |
| 276 | /// ``` |
| 277 | /// use fluent_uri::pct_enc::{encoder::Path, EStr}; |
| 278 | /// |
| 279 | /// assert_eq!( |
| 280 | /// EStr::<Path>::new_or_panic("foo;bar;baz").split_once(';'), |
| 281 | /// Some((EStr::new_or_panic("foo"), EStr::new_or_panic("bar;baz"))) |
| 282 | /// ); |
| 283 | /// |
| 284 | /// assert_eq!(EStr::<Path>::new_or_panic("foo").split_once(';'), None); |
| 285 | /// ``` |
| 286 | #[must_use] |
| 287 | pub fn split_oncerust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]split_once().(&self, delim: char) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`], &Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`])> { |
| 288 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 289 | delim.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_ascii().() && tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/::RESERVEDrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/RESERVED..allowsrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]allows().(delim), |
| 290 | "splitting with non-reserved character" |
| 291 | ); |
| 292 | self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner. |
| 293 | .split_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_once().(delim) |
| 294 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(a, b)| (Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]::new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_validated().(a), Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]::new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_validated().(b))) |
| 295 | } |
| 296 | |
| 297 | /// Splits the `EStr` slice on the last occurrence of the given delimiter and |
| 298 | /// returns prefix before delimiter and suffix after delimiter. |
| 299 | /// |
| 300 | /// Returns `None` if the delimiter is not found. |
| 301 | /// |
| 302 | /// # Panics |
| 303 | /// |
| 304 | /// Panics if the delimiter is not a [reserved] character. |
| 305 | /// |
| 306 | /// [reserved]: https://datatracker.ietf.org/doc/html/rfc3986#section-2.2 |
| 307 | /// |
| 308 | /// # Examples |
| 309 | /// |
| 310 | /// ``` |
| 311 | /// use fluent_uri::pct_enc::{encoder::Path, EStr}; |
| 312 | /// |
| 313 | /// assert_eq!( |
| 314 | /// EStr::<Path>::new_or_panic("foo;bar;baz").rsplit_once(';'), |
| 315 | /// Some((EStr::new_or_panic("foo;bar"), EStr::new_or_panic("baz"))) |
| 316 | /// ); |
| 317 | /// |
| 318 | /// assert_eq!(EStr::<Path>::new_or_panic("foo").rsplit_once(';'), None); |
| 319 | /// ``` |
| 320 | #[must_use] |
| 321 | pub fn rsplit_oncerust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]rsplit_once().(&self, delim: char) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`], &Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`])> { |
| 322 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 323 | delim.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_ascii().() && tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/::RESERVEDrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/RESERVED..allowsrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]allows().(delim), |
| 324 | "splitting with non-reserved character" |
| 325 | ); |
| 326 | self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner. |
| 327 | .rsplit_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]rsplit_once().(delim) |
| 328 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(a, b)| (Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]::new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_validated().(a), Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]::new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_validated().(b))) |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][`AsRef<Self>`]> for EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E> { |
| 333 | fn as_refrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][`AsRef<Self>`]as_ref().(&self) -> &Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][`AsRef<Self>`] { |
| 334 | self |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<str> for EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E> { |
| 339 | fn as_refrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][`AsRef<str>`]as_ref().(&self) -> &str { |
| 340 | &self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner. |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E> { |
| 345 | fn eqrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][`PartialEq<Self>`]eq().(&self, other: &Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][`PartialEq<Self>`]) -> bool { |
| 346 | self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/impl#[str][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/impl#[str][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/impl#[str][`PartialEq<Self>`]eq().other.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner. |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<str> for EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E> { |
| 351 | fn eqrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][`PartialEq<str>`]eq().(&self, other: &str) -> bool { |
| 352 | &self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().other |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E>> for str { |
| 357 | fn eqrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[str][`PartialEq<EStr<E>>`]eq().(&self, other: &EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E>) -> bool { |
| 358 | self rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().&other.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner. |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# for EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E> {} |
| 363 | |
| 364 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/::Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# for EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E> { |
| 365 | fn hashrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][Hash]hash().<H: hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/::Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#>(&self, state: &mut H) { |
| 366 | self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner..hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/impls/impl#[str][Hash]hash().(state); |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# for EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E> { |
| 371 | fn partial_cmprust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][`PartialOrd<Self>`]partial_cmp().(&self, other: &Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][`PartialOrd<Self>`]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#> { |
| 372 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.cmprust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][Ord]cmp().(other)) |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# for EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E> { |
| 377 | fn cmprust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][Ord]cmp().(&self, other: &Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][Ord]) -> Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# { |
| 378 | self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner..cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/impl#[str][Ord]cmp().(&other.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner.) |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for &EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E> { |
| 383 | /// Creates an empty `EStr` slice. |
| 384 | fn defaultrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`&EStr<E>`][Default]default().() -> Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`&EStr<E>`][Default] { |
| 385 | EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#::EMPTYrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]EMPTY. |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | #[cfg(feature = "alloc")] |
| 390 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> ToOwnedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/ToOwned# for EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E> { |
| 391 | type Ownedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][ToOwned]Owned# = EStringrust-analyzer cargo fluent-uri 0.4.1 pct_enc/estring/EString#<E>; |
| 392 | |
| 393 | fn to_ownedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][ToOwned]to_owned().(&self) -> EStringrust-analyzer cargo fluent-uri 0.4.1 pct_enc/estring/EString#<E> { |
| 394 | EStringrust-analyzer cargo fluent-uri 0.4.1 pct_enc/estring/EString#::new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/estring/impl#[`EString<E>`]new_validated().(self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner..to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()) |
| 395 | } |
| 396 | |
| 397 | fn clone_intorust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`][ToOwned]clone_into().(&self, target: &mut EStringrust-analyzer cargo fluent-uri 0.4.1 pct_enc/estring/EString#<E>) { |
| 398 | self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner..clone_intorust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]clone_into().(&mut target.bufrust-analyzer cargo fluent-uri 0.4.1 pct_enc/estring/EString#buf.); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | /// Extension methods for the [path] component. |
| 403 | /// |
| 404 | /// [path]: https://datatracker.ietf.org/doc/html/rfc3986#section-3.3 |
| 405 | impl<E: PathEncoderrust-analyzer cargo fluent-uri 0.4.1 imp/PathEncoder#> EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E> { |
| 406 | /// Checks whether the path is absolute, i.e., starting with `'/'`. |
| 407 | #[inline] |
| 408 | #[must_use] |
| 409 | pub fn is_absoluterust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]is_absolute().(&self) -> bool { |
| 410 | self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('/') |
| 411 | } |
| 412 | |
| 413 | /// Checks whether the path is rootless, i.e., not starting with `'/'`. |
| 414 | #[inline] |
| 415 | #[must_use] |
| 416 | pub fn is_rootlessrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]is_rootless().(&self) -> bool { |
| 417 | !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('/') |
| 418 | } |
| 419 | |
| 420 | /// Returns an iterator over the path segments, separated by `'/'`. |
| 421 | /// |
| 422 | /// Returns `None` if the path is [rootless]. Use [`split`] |
| 423 | /// instead if you need to split a rootless path on occurrences of `'/'`. |
| 424 | /// |
| 425 | /// Note that the path can be [empty] when authority is present, |
| 426 | /// in which case this method will return `None`. |
| 427 | /// |
| 428 | /// [rootless]: Self::is_rootless |
| 429 | /// [`split`]: Self::split |
| 430 | /// [empty]: Self::is_empty |
| 431 | /// |
| 432 | /// # Examples |
| 433 | /// |
| 434 | /// ``` |
| 435 | /// use fluent_uri::Uri; |
| 436 | /// |
| 437 | /// // Segments are separated by '/'. |
| 438 | /// // The empty string before a leading '/' is not a segment. |
| 439 | /// // However, segments can be empty in the other cases. |
| 440 | /// let path = Uri::parse("file:///path/to//dir/")?.path(); |
| 441 | /// assert_eq!(path, "/path/to//dir/"); |
| 442 | /// assert!(path.segments_if_absolute().unwrap().eq(["path", "to", "", "dir", ""])); |
| 443 | /// |
| 444 | /// let path = Uri::parse("foo:bar/baz")?.path(); |
| 445 | /// assert_eq!(path, "bar/baz"); |
| 446 | /// assert!(path.segments_if_absolute().is_none()); |
| 447 | /// |
| 448 | /// let path = Uri::parse("http://example.com")?.path(); |
| 449 | /// assert!(path.is_empty()); |
| 450 | /// assert!(path.segments_if_absolute().is_none()); |
| 451 | /// # Ok::<_, fluent_uri::ParseError>(()) |
| 452 | /// ``` |
| 453 | #[inline] |
| 454 | #[must_use] |
| 455 | pub fn segments_if_absoluterust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]segments_if_absolute().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Splitrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split#<'_, E>> { |
| 456 | self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#inner. |
| 457 | .strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().('/') |
| 458 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|s| Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]::new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_validated().(s).splitrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]split().('/')) |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | const fn gen_octet_tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/gen_octet_table().(hi: bool) -> [u8; 256] { |
| 463 | let mut out = [0xff; 256]; |
| 464 | let shift = if hi { 4 } else { 0 }; |
| 465 | |
| 466 | let mut i = 0; |
| 467 | while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().10 { |
| 468 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().(i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().b'0') as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().shift; |
| 469 | i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign().1; |
| 470 | } |
| 471 | while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialOrd<Self>`]lt().16 { |
| 472 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().(i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().10 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().b'A') as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().shift; |
| 473 | out[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().(i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Sub<Self>`]sub().10 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`Add<Self>`]add().b'a') as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().<<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`Shl<i32>`]shl().shift; |
| 474 | i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u8][`AddAssign<Self>`]add_assign().1; |
| 475 | } |
| 476 | out |
| 477 | } |
| 478 | |
| 479 | const OCTET_TABLE_HIrust-analyzer cargo fluent-uri 0.4.1 pct_enc/OCTET_TABLE_HI.: &[u8; 256] = &gen_octet_tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/gen_octet_table().(true); |
| 480 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) const OCTET_TABLE_LOrust-analyzer cargo fluent-uri 0.4.1 pct_enc/OCTET_TABLE_LO.: &[u8; 256] = &gen_octet_tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/gen_octet_table().(false); |
| 481 | |
| 482 | /// Decodes a percent-encoded octet, assuming that the bytes are hexadecimal. |
| 483 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) fn decode_octetrust-analyzer cargo fluent-uri 0.4.1 pct_enc/decode_octet().(hi: u8, lo: u8) -> u8 { |
| 484 | debug_assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert!!(hi.is_ascii_hexdigitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii_hexdigit().() && lo.is_ascii_hexdigitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u8]is_ascii_hexdigit().()); |
| 485 | OCTET_TABLE_HIrust-analyzer cargo fluent-uri 0.4.1 pct_enc/OCTET_TABLE_HI.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().hi as usize]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/bit/impl#[u8][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u8][`BitOr<Self>`]bitor().OCTET_TABLE_LOrust-analyzer cargo fluent-uri 0.4.1 pct_enc/OCTET_TABLE_LO.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().lo as usize]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 486 | } |
| 487 | |
| 488 | /// An iterator used to decode an [`EStr`] slice. |
| 489 | /// |
| 490 | /// This struct is created by [`EStr::decode`]. Normally you'll use the methods below |
| 491 | /// instead of iterating over a `Decode` manually, unless you need precise control |
| 492 | /// over allocation. |
| 493 | /// |
| 494 | /// See the [`DecodedChunk`] type for documentation of the items yielded by this iterator. |
| 495 | #[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:)] |
| 496 | #[must_use = "iterators are lazy and do nothing unless consumed"] |
| 497 | pub struct Decoderust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#<'a> { |
| 498 | sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source.: &'a str, |
| 499 | } |
| 500 | |
| 501 | /// An item returned by the [`Decode`] iterator. |
| 502 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 503 | pub enum DecodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#<'a> { |
| 504 | /// An unencoded subslice. |
| 505 | Unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#Unencoded#(&'a str), |
| 506 | /// A percent-encoded octet, decoded (for example, `"%20"` decoded as `0x20`). |
| 507 | PctDecodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#PctDecoded#(u8), |
| 508 | } |
| 509 | |
| 510 | impl<'a> Decoderust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#<'a> { |
| 511 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) fn newrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]new().(source: &'a str) -> Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`] { |
| 512 | Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`] { sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source. } |
| 513 | } |
| 514 | |
| 515 | fn next_if_unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]next_if_unencoded().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a str> { |
| 516 | let i = self |
| 517 | .sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source. |
| 518 | .bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]bytes().() |
| 519 | .positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Bytes<'_>`][Iterator]position().(|x| x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'%') |
| 520 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()); |
| 521 | |
| 522 | if i 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 { |
| 523 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 524 | } else { |
| 525 | let s; |
| 526 | (s, self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source.) = self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source..split_atrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_at().(i); |
| 527 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) |
| 528 | } |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Decoderust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#<'a> { |
| 533 | type Itemrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`][Iterator]Item# = DecodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#<'a>; |
| 534 | |
| 535 | fn nextrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 536 | if self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 537 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 538 | } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) = self.next_if_unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]next_if_unencoded().() { |
| 539 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(DecodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#::Unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#Unencoded#(s)) |
| 540 | } else { |
| 541 | let s; |
| 542 | (s, self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source.) = self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source..split_atrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_at().(3); |
| 543 | let x = decode_octetrust-analyzer cargo fluent-uri 0.4.1 pct_enc/decode_octet().(s.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., s.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()[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().); |
| 544 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(DecodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#::PctDecodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#PctDecoded#(x)) |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | impl FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for Decoderust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#<'_> {} |
| 550 | |
| 551 | #[cfg(feature = "alloc")] |
| 552 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) enum DecodedUtf8Chunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#<'a, 'b> { |
| 553 | Unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Unencoded#(&'a str), |
| 554 | Decodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded# { validrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#valid.: &'b str, invalidrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#invalid.: &'b [u8] }, |
| 555 | } |
| 556 | |
| 557 | #[cfg(feature = "alloc")] |
| 558 | impl<'a> Decoderust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#<'a> { |
| 559 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) fn decode_utf8rust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]decode_utf8().(self, mut handle_chunk: impl FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(DecodedUtf8Chunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#<'a, '_>)) { |
| 560 | use craterust-analyzer cargo fluent-uri 0.4.1 crate/::utf8rust-analyzer cargo fluent-uri 0.4.1 utf8/::Utf8Chunksrust-analyzer cargo fluent-uri 0.4.1 utf8/Utf8Chunks#; |
| 561 | |
| 562 | let mut buf = [0; 32]; |
| 563 | let mut len = 0; |
| 564 | |
| 565 | 'decode: for chunk in self { |
| 566 | match chunk { |
| 567 | DecodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#::Unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#Unencoded#(s) => { |
| 568 | if len 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 { |
| 569 | for chunk in Utf8Chunksrust-analyzer cargo fluent-uri 0.4.1 utf8/Utf8Chunks#::newrust-analyzer cargo fluent-uri 0.4.1 utf8/impl#[`Utf8Chunks<'a>`]new().(&buf[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/RangeTo#len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().) { |
| 570 | handle_chunk(DecodedUtf8Chunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#::Decodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded# { |
| 571 | validrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#valid.: chunk.validrust-analyzer cargo fluent-uri 0.4.1 utf8/impl#[`Utf8Chunk<'a>`]valid().(), |
| 572 | invalidrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#invalid.: chunk.invalidrust-analyzer cargo fluent-uri 0.4.1 utf8/impl#[`Utf8Chunk<'a>`]invalid().(), |
| 573 | }); |
| 574 | } |
| 575 | len = 0; |
| 576 | } |
| 577 | handle_chunk(DecodedUtf8Chunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#::Unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Unencoded#(s)); |
| 578 | } |
| 579 | DecodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#::PctDecodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#PctDecoded#(x) => { |
| 580 | buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = x; |
| 581 | len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 582 | |
| 583 | if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 584 | for chunk in Utf8Chunksrust-analyzer cargo fluent-uri 0.4.1 utf8/Utf8Chunks#::newrust-analyzer cargo fluent-uri 0.4.1 utf8/impl#[`Utf8Chunks<'a>`]new().(&buf[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/RangeTo#len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().) { |
| 585 | if chunk.incompleterust-analyzer cargo fluent-uri 0.4.1 utf8/impl#[`Utf8Chunk<'a>`]incomplete().() { |
| 586 | handle_chunk(DecodedUtf8Chunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#::Decodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded# { |
| 587 | validrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#valid.: chunk.validrust-analyzer cargo fluent-uri 0.4.1 utf8/impl#[`Utf8Chunk<'a>`]valid().(), |
| 588 | invalidrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#invalid.: &[], |
| 589 | }); |
| 590 | |
| 591 | let invalid_len = chunk.invalidrust-analyzer cargo fluent-uri 0.4.1 utf8/impl#[`Utf8Chunk<'a>`]invalid().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(); |
| 592 | buf.copy_withinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_within().(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().invalid_len..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#len, 0); |
| 593 | |
| 594 | len = invalid_len; |
| 595 | continue 'decode; |
| 596 | } |
| 597 | handle_chunk(DecodedUtf8Chunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#::Decodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded# { |
| 598 | validrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#valid.: chunk.validrust-analyzer cargo fluent-uri 0.4.1 utf8/impl#[`Utf8Chunk<'a>`]valid().(), |
| 599 | invalidrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#invalid.: chunk.invalidrust-analyzer cargo fluent-uri 0.4.1 utf8/impl#[`Utf8Chunk<'a>`]invalid().(), |
| 600 | }); |
| 601 | } |
| 602 | len = 0; |
| 603 | } |
| 604 | } |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | for chunk in Utf8Chunksrust-analyzer cargo fluent-uri 0.4.1 utf8/Utf8Chunks#::newrust-analyzer cargo fluent-uri 0.4.1 utf8/impl#[`Utf8Chunks<'a>`]new().(&buf[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/RangeTo#len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().) { |
| 609 | handle_chunk(DecodedUtf8Chunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#::Decodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded# { |
| 610 | validrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#valid.: chunk.validrust-analyzer cargo fluent-uri 0.4.1 utf8/impl#[`Utf8Chunk<'a>`]valid().(), |
| 611 | invalidrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#invalid.: chunk.invalidrust-analyzer cargo fluent-uri 0.4.1 utf8/impl#[`Utf8Chunk<'a>`]invalid().(), |
| 612 | }); |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | fn decoded_lenrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]decoded_len().(&self) -> usize { |
| 617 | self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]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().self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source..bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]bytes().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|&x| x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'%').countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]count().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().2 |
| 618 | } |
| 619 | |
| 620 | fn borrow_all_or_prep_bufrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]borrow_all_or_prep_buf().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&'a str, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 621 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) = self.next_if_unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]next_if_unencoded().() { |
| 622 | if self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 623 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s); |
| 624 | } |
| 625 | let mut buf = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]with_capacity().(s.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() 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().self.decoded_lenrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]decoded_len().()); |
| 626 | buf.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(s); |
| 627 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(buf) |
| 628 | } else { |
| 629 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]with_capacity().(self.decoded_lenrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]decoded_len().())) |
| 630 | } |
| 631 | } |
| 632 | |
| 633 | /// Decodes the slice to bytes. |
| 634 | /// |
| 635 | /// This method allocates only when the slice contains any percent-encoded octet. |
| 636 | #[must_use] |
| 637 | pub fn to_bytesrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]to_bytes().(mut self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'a, [u8]> { |
| 638 | if self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 639 | return Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(&[]); |
| 640 | } |
| 641 | |
| 642 | let mut buf = match self.borrow_all_or_prep_bufrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]borrow_all_or_prep_buf().() { |
| 643 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s) => return Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(s.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()), |
| 644 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(buf) => buf.into_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]into_bytes().(), |
| 645 | }; |
| 646 | |
| 647 | for chunk in self { |
| 648 | match chunk { |
| 649 | DecodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#::Unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#Unencoded#(s) => buf.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(s.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()), |
| 650 | DecodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#::PctDecodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedChunk#PctDecoded#(s) => buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(s), |
| 651 | } |
| 652 | } |
| 653 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(buf) |
| 654 | } |
| 655 | |
| 656 | /// Attempts to decode the slice to a string. |
| 657 | /// |
| 658 | /// This method allocates only when the slice contains any percent-encoded octet. |
| 659 | /// |
| 660 | /// # Errors |
| 661 | /// |
| 662 | /// Returns `Err` containing the decoded bytes if they are not valid UTF-8. |
| 663 | pub fn to_stringrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]to_string().(mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'a, str>, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> { |
| 664 | if self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 665 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#("")); |
| 666 | } |
| 667 | |
| 668 | let mut buf = match self.borrow_all_or_prep_bufrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]borrow_all_or_prep_buf().() { |
| 669 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s) => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(s)), |
| 670 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(buf) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#::<_, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>>(buf), |
| 671 | }; |
| 672 | |
| 673 | self.decode_utf8rust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]decode_utf8().(|chunk| match chunk { |
| 674 | DecodedUtf8Chunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#::Unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Unencoded#(s) => match &mut buf { |
| 675 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(string) => string.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(s), |
| 676 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(vec) => vec.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(s.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()), |
| 677 | }, |
| 678 | DecodedUtf8Chunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#::Decodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded# { validrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#valid., invalidrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#invalid. } => match &mut buf { |
| 679 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(string) => { |
| 680 | string.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(valid); |
| 681 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().invalid.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() { |
| 682 | let mut vec = corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/take().(string).into_bytesrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]into_bytes().(); |
| 683 | vec.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(invalid); |
| 684 | buf = Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(vec); |
| 685 | } |
| 686 | } |
| 687 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(vec) => { |
| 688 | vec.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(valid.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()); |
| 689 | vec.extend_from_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]extend_from_slice().(invalid); |
| 690 | } |
| 691 | }, |
| 692 | }); |
| 693 | |
| 694 | match buf { |
| 695 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(buf) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(buf)), |
| 696 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(buf) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(buf), |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | /// Decodes the slice to a string, replacing any invalid UTF-8 sequences with |
| 701 | /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD]. |
| 702 | /// |
| 703 | /// [U+FFFD]: char::REPLACEMENT_CHARACTER |
| 704 | /// |
| 705 | /// This method allocates only when the slice contains any percent-encoded octet. |
| 706 | #[must_use] |
| 707 | pub fn to_string_lossyrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]to_string_lossy().(mut self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'a, str> { |
| 708 | if self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Decode#source..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 709 | return Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(""); |
| 710 | } |
| 711 | |
| 712 | let mut buf = match self.borrow_all_or_prep_bufrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]borrow_all_or_prep_buf().() { |
| 713 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s) => return Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Borrowedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Borrowed#(s), |
| 714 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(buf) => buf, |
| 715 | }; |
| 716 | |
| 717 | self.decode_utf8rust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Decode<'a>`]decode_utf8().(|chunk| match chunk { |
| 718 | DecodedUtf8Chunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#::Unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Unencoded#(s) => buf.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(s), |
| 719 | DecodedUtf8Chunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#::Decodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded# { validrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#valid., invalidrust-analyzer cargo fluent-uri 0.4.1 pct_enc/DecodedUtf8Chunk#Decoded#invalid. } => { |
| 720 | buf.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(valid); |
| 721 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().invalid.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() { |
| 722 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(char::REPLACEMENT_CHARACTERrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]REPLACEMENT_CHARACTER.); |
| 723 | } |
| 724 | } |
| 725 | }); |
| 726 | Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#::Ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#Owned#(buf) |
| 727 | } |
| 728 | } |
| 729 | |
| 730 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) fn encode_byterust-analyzer cargo fluent-uri 0.4.1 pct_enc/encode_byte().(x: u8) -> &'static str { |
| 731 | const TABLErust-analyzer cargo fluent-uri 0.4.1 pct_enc/TABLE.: &[u8; 256 * 3] = &{ |
| 732 | const HEX_DIGITSrust-analyzer cargo fluent-uri 0.4.1 pct_enc/HEX_DIGITS.: &[u8; 16] = b"0123456789ABCDEF"; |
| 733 | |
| 734 | let mut i = 0; |
| 735 | let mut table = [0; 256 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().3]; |
| 736 | while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().256 { |
| 737 | table[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = b'%'; |
| 738 | table[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().3 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 array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = HEX_DIGITSrust-analyzer cargo fluent-uri 0.4.1 pct_enc/HEX_DIGITS.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`Shr<i32>`]shr().4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 739 | table[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().3 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().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = HEX_DIGITSrust-analyzer cargo fluent-uri 0.4.1 pct_enc/HEX_DIGITS.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[usize][`BitAnd<Self>`]bitand().0b1111]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 740 | i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 741 | } |
| 742 | table |
| 743 | }; |
| 744 | |
| 745 | const TABLE_STRrust-analyzer cargo fluent-uri 0.4.1 pct_enc/TABLE_STR.: &str = match strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(TABLErust-analyzer cargo fluent-uri 0.4.1 pct_enc/TABLE.) { |
| 746 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s) => s, |
| 747 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!(), |
| 748 | }; |
| 749 | |
| 750 | &TABLE_STRrust-analyzer cargo fluent-uri 0.4.1 pct_enc/TABLE_STR.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().x as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().3..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#x as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().3 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().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). |
| 751 | } |
| 752 | |
| 753 | /// An iterator used to percent-encode a string slice. |
| 754 | /// |
| 755 | /// This struct is created by [`Table::encode`]. Normally you'll use [`EString::encode_str`] |
| 756 | /// instead, unless you need precise control over allocation. |
| 757 | /// |
| 758 | /// See the [`EncodedChunk`] type for documentation of the items yielded by this iterator. |
| 759 | #[cfg(feature = "alloc")] |
| 760 | #[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:)] |
| 761 | #[must_use = "iterators are lazy and do nothing unless consumed"] |
| 762 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) struct Encoderust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#<'t, 's> { |
| 763 | tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#table.: &'t Tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/Table#, |
| 764 | sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source.: &'s str, |
| 765 | enc_lenrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_len.: usize, |
| 766 | enc_irust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_i.: usize, |
| 767 | } |
| 768 | |
| 769 | #[cfg(feature = "alloc")] |
| 770 | impl<'t, 's> Encoderust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#<'t, 's> { |
| 771 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) fn newrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Encode<'t, 's>`]new().(table: &'t Tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/Table#, source: &'s str) -> Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Encode<'t, 's>`] { |
| 772 | Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Encode<'t, 's>`] { |
| 773 | tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#table., |
| 774 | sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source., |
| 775 | enc_lenrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_len.: 0, |
| 776 | enc_irust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_i.: 0, |
| 777 | } |
| 778 | } |
| 779 | } |
| 780 | |
| 781 | /// An item returned by the [`Encode`] iterator. |
| 782 | #[cfg(feature = "alloc")] |
| 783 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, 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:)] |
| 784 | pub(craterust-analyzer cargo fluent-uri 0.4.1 crate/) enum EncodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#<'a> { |
| 785 | /// An unencoded subslice. |
| 786 | Unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#Unencoded#(&'a str), |
| 787 | /// A byte, percent-encoded (for example, `0x20` encoded as `"%20"`). |
| 788 | PctEncodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#PctEncoded#(&'static str), |
| 789 | } |
| 790 | |
| 791 | #[cfg(feature = "alloc")] |
| 792 | impl<'a> EncodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#<'a> { |
| 793 | /// Returns the chunk as a string slice. |
| 794 | #[must_use] |
| 795 | pub fn as_strrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EncodedChunk<'a>`]as_str().(self) -> &'a str { |
| 796 | match self { |
| 797 | Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EncodedChunk<'a>`]::Unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#Unencoded#(s) | Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EncodedChunk<'a>`]::PctEncodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#PctEncoded#(s) => s, |
| 798 | } |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | #[cfg(feature = "alloc")] |
| 803 | impl<'t, 's> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Encoderust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#<'t, 's> { |
| 804 | type Itemrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Encode<'t, 's>`][Iterator]Item# = EncodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#<'s>; |
| 805 | |
| 806 | fn nextrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Encode<'t, 's>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Encode<'t, 's>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 807 | if self.enc_irust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_i. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.enc_lenrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_len. { |
| 808 | let s = encode_byterust-analyzer cargo fluent-uri 0.4.1 pct_enc/encode_byte().(self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source..as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.enc_irust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_i.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 809 | self.enc_irust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_i. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 810 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(EncodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#::PctEncodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#PctEncoded#(s)); |
| 811 | } |
| 812 | |
| 813 | self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source. = &self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.enc_lenrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_len...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 814 | self.enc_lenrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_len. = 0; |
| 815 | |
| 816 | if self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source..is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 817 | return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 818 | } |
| 819 | |
| 820 | let mut iter = self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source..char_indicesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]char_indices().(); |
| 821 | let i = iter |
| 822 | .find_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find_map().(|(i, ch)| (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.tablerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#table..allowsrust-analyzer cargo fluent-uri 0.4.1 pct_enc/table/impl#[Table]allows().(ch)).then_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then_some().(i)) |
| 823 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()); |
| 824 | |
| 825 | // `CharIndices::offset` sadly requires an MSRV of 1.82, |
| 826 | // so we do pointer math to get the offset for now. |
| 827 | if i 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 { |
| 828 | self.enc_lenrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_len. = iter.as_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`CharIndices<'a>`]as_str().().as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]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.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source..as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_ptr().() as usize; |
| 829 | self.enc_irust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_i. = 1; |
| 830 | |
| 831 | let s = encode_byterust-analyzer cargo fluent-uri 0.4.1 pct_enc/encode_byte().(self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source..as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()[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().); |
| 832 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(EncodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#::PctEncodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#PctEncoded#(s)) |
| 833 | } else { |
| 834 | let s; |
| 835 | (s, self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source.) = self.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source..split_atrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_at().(i); |
| 836 | |
| 837 | self.enc_lenrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_len. = iter.as_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`CharIndices<'a>`]as_str().().as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]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.sourcerust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#source..as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_ptr().() as usize; |
| 838 | self.enc_irust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#enc_i. = 0; |
| 839 | |
| 840 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(EncodedChunkrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#::Unencodedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EncodedChunk#Unencoded#(s)) |
| 841 | } |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | #[cfg(feature = "alloc")] |
| 846 | impl FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for Encoderust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encode#<'_, '_> {} |
| 847 | |
| 848 | /// An iterator over subslices of an [`EStr`] slice separated by a delimiter. |
| 849 | /// |
| 850 | /// This struct is created by [`EStr::split`]. |
| 851 | #[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:)] |
| 852 | #[must_use = "iterators are lazy and do nothing unless consumed"] |
| 853 | pub struct Splitrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split#<'a, E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> { |
| 854 | innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split#inner.: strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/::Splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/Split#<'a, char>, |
| 855 | encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split#encoder.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<E>, |
| 856 | } |
| 857 | |
| 858 | impl<'a, E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Splitrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split#<'a, E> { |
| 859 | type Itemrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Split<'a, E>`][Iterator]Item# = &'a EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E>; |
| 860 | |
| 861 | fn nextrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Split<'a, E>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E>> { |
| 862 | self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split#inner..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][Iterator]next().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#::new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_validated().) |
| 863 | } |
| 864 | } |
| 865 | |
| 866 | impl<'a, E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for Splitrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split#<'a, E> { |
| 867 | fn next_backrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`Split<'a, E>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#<E>> { |
| 868 | self.innerrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split#inner..next_backrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`Split<'a, P>`][DoubleEndedIterator]next_back().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(EStrrust-analyzer cargo fluent-uri 0.4.1 pct_enc/EStr#::new_validatedrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]new_validated().) |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | impl<E: Encoderrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Encoder#> FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator# for Splitrust-analyzer cargo fluent-uri 0.4.1 pct_enc/Split#<'_, E> {} |