| 1 | use craterust-analyzer cargo fluent-uri 0.4.1 crate/::{imprust-analyzer cargo fluent-uri 0.4.1 imp/::RiMaybeRefrust-analyzer cargo fluent-uri 0.4.1 imp/RiMaybeRef#, Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#, IriRefrust-analyzer cargo fluent-uri 0.4.1 imp/IriRef#, Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#, UriRefrust-analyzer cargo fluent-uri 0.4.1 imp/UriRef#}; |
| 2 | use borrow_or_sharerust-analyzer cargo borrow-or-share 0.2.4 crate/::Bosrust-analyzer cargo borrow-or-share 0.2.4 Bos#; |
| 3 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/; |
| 4 | |
| 5 | #[cfg(feature = "alloc")] |
| 6 | use craterust-analyzer cargo fluent-uri 0.4.1 crate/::{ |
| 7 | imprust-analyzer cargo fluent-uri 0.4.1 imp/::{HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#, Metarust-analyzer cargo fluent-uri 0.4.1 imp/Meta#, RmrRefrust-analyzer cargo fluent-uri 0.4.1 imp/RmrRef#}, |
| 8 | pct_encrust-analyzer cargo fluent-uri 0.4.1 pct_enc/, |
| 9 | }; |
| 10 | #[cfg(feature = "alloc")] |
| 11 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#; |
| 12 | #[cfg(feature = "alloc")] |
| 13 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::numrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/::NonZeroUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroUsize#; |
| 14 | |
| 15 | macro_rules! impl_fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl_from! { |
| 16 | ($($x:ident => $($y:ident),+)*) => { |
| 17 | $($( |
| 18 | impl<T: Bos<str>> From<$x<T>> for $y<T> { |
| 19 | #[doc = concat!("Consumes the `", stringify!($x), "` and creates a new [`", stringify!($y), "`] with the same contents.")] |
| 20 | fn from(value: $x<T>) -> Self { |
| 21 | RiMaybeRef::new(value.val, value.meta) |
| 22 | } |
| 23 | } |
| 24 | )+)* |
| 25 | }; |
| 26 | } |
| 27 | |
| 28 | impl_fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl_from!! { |
| 29 | Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri# => UriRefrust-analyzer cargo fluent-uri 0.4.1 imp/UriRef#, Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#, IriRefrust-analyzer cargo fluent-uri 0.4.1 imp/IriRef# |
| 30 | UriRefrust-analyzer cargo fluent-uri 0.4.1 imp/UriRef# => IriRefrust-analyzer cargo fluent-uri 0.4.1 imp/IriRef# |
| 31 | Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri# => IriRefrust-analyzer cargo fluent-uri 0.4.1 imp/IriRef# |
| 32 | } |
| 33 | |
| 34 | /// An error occurred when downcasting a URI/IRI (reference). |
| 35 | #[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:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 36 | pub enum ConvertErrorrust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError# { |
| 37 | /// The input is not ASCII. |
| 38 | NotAsciirust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#NotAscii# { |
| 39 | /// The index of the first non-ASCII character. |
| 40 | indexrust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#NotAscii#index.: usize, |
| 41 | }, |
| 42 | /// The input has no scheme. |
| 43 | NoSchemerust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError#NoScheme#, |
| 44 | } |
| 45 | |
| 46 | #[cfg(feature = "impl-error")] |
| 47 | impl craterust-analyzer cargo fluent-uri 0.4.1 crate/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for ConvertErrorrust-analyzer cargo fluent-uri 0.4.1 convert/ConvertError# {} |
| 48 | |
| 49 | macro_rules! impl_try_fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl_try_from! { |
| 50 | ($(#[$doc:meta] $x:ident if $($cond:ident)&&+ => $y:ident)*) => { |
| 51 | $( |
| 52 | impl<'a> TryFrom<$x<&'a str>> for $y<&'a str> { |
| 53 | type Error = ConvertError; |
| 54 | |
| 55 | #[$doc] |
| 56 | fn try_from(value: $x<&'a str>) -> Result<Self, Self::Error> { |
| 57 | let r = value.make_ref(); |
| 58 | $(r.$cond()?;)+ |
| 59 | Ok(RiMaybeRef::new(value.val, value.meta)) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | #[cfg(feature = "alloc")] |
| 64 | impl TryFrom<$x<String>> for $y<String> { |
| 65 | type Error = (ConvertError, $x<String>); |
| 66 | |
| 67 | #[$doc] |
| 68 | fn try_from(value: $x<String>) -> Result<Self, Self::Error> { |
| 69 | let r = value.make_ref(); |
| 70 | $( |
| 71 | if let Err(e) = r.$cond() { |
| 72 | return Err((e, value)); |
| 73 | } |
| 74 | )+ |
| 75 | Ok(RiMaybeRef::new(value.val, value.meta)) |
| 76 | } |
| 77 | } |
| 78 | )* |
| 79 | }; |
| 80 | } |
| 81 | |
| 82 | impl_try_fromrust-analyzer cargo fluent-uri 0.4.1 convert/impl_try_from!! { |
| 83 | /// Converts the URI reference to a URI if it has a scheme. |
| 84 | UriRefrust-analyzer cargo fluent-uri 0.4.1 imp/UriRef# if ensure_has_schemerust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`RmrRef<'v, 'm>`]ensure_has_scheme(). => Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri# |
| 85 | /// Converts the IRI to a URI if it is ASCII. |
| 86 | Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri# if ensure_asciirust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`RmrRef<'v, 'm>`]ensure_ascii(). => Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri# |
| 87 | /// Converts the IRI reference to a URI if it has a scheme and is ASCII. |
| 88 | IriRefrust-analyzer cargo fluent-uri 0.4.1 imp/IriRef# if ensure_has_schemerust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`RmrRef<'v, 'm>`]ensure_has_scheme(). && ensure_asciirust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`RmrRef<'v, 'm>`]ensure_ascii(). => Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri# |
| 89 | /// Converts the IRI reference to a URI reference if it is ASCII. |
| 90 | IriRefrust-analyzer cargo fluent-uri 0.4.1 imp/IriRef# if ensure_asciirust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`RmrRef<'v, 'm>`]ensure_ascii(). => UriRefrust-analyzer cargo fluent-uri 0.4.1 imp/UriRef# |
| 91 | /// Converts the IRI reference to an IRI if it has a scheme. |
| 92 | IriRefrust-analyzer cargo fluent-uri 0.4.1 imp/IriRef# if ensure_has_schemerust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`RmrRef<'v, 'm>`]ensure_has_scheme(). => Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri# |
| 93 | } |
| 94 | |
| 95 | #[cfg(feature = "alloc")] |
| 96 | impl<T: Bosrust-analyzer cargo borrow-or-share 0.2.4 Bos#<str>> Irirust-analyzer cargo fluent-uri 0.4.1 imp/Iri#<T> { |
| 97 | /// Converts the IRI to a URI by percent-encoding non-ASCII characters. |
| 98 | /// |
| 99 | /// Punycode encoding is **not** performed during conversion. |
| 100 | /// |
| 101 | /// # Examples |
| 102 | /// |
| 103 | /// ``` |
| 104 | /// use fluent_uri::Iri; |
| 105 | /// |
| 106 | /// let iri = Iri::parse("http://www.example.org/résumé.html").unwrap(); |
| 107 | /// assert_eq!(iri.to_uri(), "http://www.example.org/r%C3%A9sum%C3%A9.html"); |
| 108 | /// |
| 109 | /// let iri = Iri::parse("http://résumé.example.org").unwrap(); |
| 110 | /// assert_eq!(iri.to_uri(), "http://r%C3%A9sum%C3%A9.example.org"); |
| 111 | /// ``` |
| 112 | pub fn to_urirust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`Iri<T>`]to_uri().(&self) -> Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 113 | RiMaybeRefrust-analyzer cargo fluent-uri 0.4.1 imp/RiMaybeRef#::from_pairrust-analyzer cargo fluent-uri 0.4.1 imp/RiMaybeRef#from_pair().(encode_non_asciirust-analyzer cargo fluent-uri 0.4.1 convert/encode_non_ascii().(self.make_refrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Iri<T>`][RiMaybeRef]make_ref().())) |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | #[cfg(feature = "alloc")] |
| 118 | impl<T: Bosrust-analyzer cargo borrow-or-share 0.2.4 Bos#<str>> IriRefrust-analyzer cargo fluent-uri 0.4.1 imp/IriRef#<T> { |
| 119 | /// Converts the IRI reference to a URI reference by percent-encoding non-ASCII characters. |
| 120 | /// |
| 121 | /// Punycode encoding is **not** performed during conversion. |
| 122 | /// |
| 123 | /// # Examples |
| 124 | /// |
| 125 | /// ``` |
| 126 | /// use fluent_uri::IriRef; |
| 127 | /// |
| 128 | /// let iri_ref = IriRef::parse("résumé.html").unwrap(); |
| 129 | /// assert_eq!(iri_ref.to_uri_ref(), "r%C3%A9sum%C3%A9.html"); |
| 130 | /// |
| 131 | /// let iri_ref = IriRef::parse("//résumé.example.org").unwrap(); |
| 132 | /// assert_eq!(iri_ref.to_uri_ref(), "//r%C3%A9sum%C3%A9.example.org"); |
| 133 | /// ``` |
| 134 | pub fn to_uri_refrust-analyzer cargo fluent-uri 0.4.1 convert/impl#[`IriRef<T>`]to_uri_ref().(&self) -> UriRefrust-analyzer cargo fluent-uri 0.4.1 imp/UriRef#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 135 | RiMaybeRefrust-analyzer cargo fluent-uri 0.4.1 imp/RiMaybeRef#::from_pairrust-analyzer cargo fluent-uri 0.4.1 imp/RiMaybeRef#from_pair().(encode_non_asciirust-analyzer cargo fluent-uri 0.4.1 convert/encode_non_ascii().(self.make_refrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`IriRef<T>`][RiMaybeRef]make_ref().())) |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | #[cfg(feature = "alloc")] |
| 140 | fn encode_non_asciirust-analyzer cargo fluent-uri 0.4.1 convert/encode_non_ascii().(r: RmrRefrust-analyzer cargo fluent-uri 0.4.1 imp/RmrRef#<'_, '_>) -> (Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Metarust-analyzer cargo fluent-uri 0.4.1 imp/Meta#) { |
| 141 | let len = r |
| 142 | .as_strrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`RmrRef<'v, 'm>`]as_str().() |
| 143 | .charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().() |
| 144 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|c| if c.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_ascii().() { 1 } else { c.len_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]len_utf8().() 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 }) |
| 145 | .sumrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#sum().(); |
| 146 | |
| 147 | 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().(len); |
| 148 | let mut meta = Metarust-analyzer cargo fluent-uri 0.4.1 imp/Meta#::defaultrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[Meta][Default]default().(); |
| 149 | |
| 150 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(scheme) = r.scheme_optrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`RmrRef<'v, 'm>`]scheme_opt().() { |
| 151 | buf.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(scheme.as_strrust-analyzer cargo fluent-uri 0.4.1 component/impl#[Scheme]as_str().()); |
| 152 | meta.scheme_endrust-analyzer cargo fluent-uri 0.4.1 imp/Meta#scheme_end. = NonZeroUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroUsize#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]new().(buf.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().()); |
| 153 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(':'); |
| 154 | } |
| 155 | |
| 156 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(auth) = r.authorityrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`RmrRef<'v, 'm>`]authority().() { |
| 157 | buf.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().("//"); |
| 158 | |
| 159 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(userinfo) = auth.userinforust-analyzer cargo fluent-uri 0.4.1 component/impl#[`Authority<'a, UserinfoE, RegNameE>`]userinfo().() { |
| 160 | encode_non_ascii_strrust-analyzer cargo fluent-uri 0.4.1 convert/encode_non_ascii_str().(&mut buf, userinfo.as_strrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]as_str().()); |
| 161 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('@'); |
| 162 | } |
| 163 | |
| 164 | let mut auth_meta = auth.metarust-analyzer cargo fluent-uri 0.4.1 component/impl#[`Authority<'a, UserinfoE, RegNameE>`]meta().(); |
| 165 | auth_meta.host_boundsrust-analyzer cargo fluent-uri 0.4.1 imp/AuthMeta#host_bounds..0 = buf.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().(); |
| 166 | match auth_meta.host_metarust-analyzer cargo fluent-uri 0.4.1 imp/AuthMeta#host_meta. { |
| 167 | HostMetarust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#::RegNamerust-analyzer cargo fluent-uri 0.4.1 imp/HostMeta#RegName# => encode_non_ascii_strrust-analyzer cargo fluent-uri 0.4.1 convert/encode_non_ascii_str().(&mut buf, auth.hostrust-analyzer cargo fluent-uri 0.4.1 component/impl#[`Authority<'a, UserinfoE, RegNameE>`]host().()), |
| 168 | _ => buf.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(auth.hostrust-analyzer cargo fluent-uri 0.4.1 component/impl#[`Authority<'a, UserinfoE, RegNameE>`]host().()), |
| 169 | } |
| 170 | auth_meta.host_boundsrust-analyzer cargo fluent-uri 0.4.1 imp/AuthMeta#host_bounds..1 = buf.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().(); |
| 171 | meta.auth_metarust-analyzer cargo fluent-uri 0.4.1 imp/Meta#auth_meta. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(auth_meta); |
| 172 | |
| 173 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(port) = auth.portrust-analyzer cargo fluent-uri 0.4.1 component/impl#[`Authority<'a, UserinfoE, RegNameE>`]port().() { |
| 174 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(':'); |
| 175 | buf.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(port.as_strrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]as_str().()); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | meta.path_boundsrust-analyzer cargo fluent-uri 0.4.1 imp/Meta#path_bounds..0 = buf.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().(); |
| 180 | encode_non_ascii_strrust-analyzer cargo fluent-uri 0.4.1 convert/encode_non_ascii_str().(&mut buf, r.pathrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`RmrRef<'v, 'm>`]path().().as_strrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]as_str().()); |
| 181 | meta.path_boundsrust-analyzer cargo fluent-uri 0.4.1 imp/Meta#path_bounds..1 = buf.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().(); |
| 182 | |
| 183 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(query) = r.queryrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`RmrRef<'v, 'm>`]query().() { |
| 184 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('?'); |
| 185 | encode_non_ascii_strrust-analyzer cargo fluent-uri 0.4.1 convert/encode_non_ascii_str().(&mut buf, query.as_strrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]as_str().()); |
| 186 | meta.query_endrust-analyzer cargo fluent-uri 0.4.1 imp/Meta#query_end. = NonZeroUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroUsize#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]new().(buf.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().()); |
| 187 | } |
| 188 | |
| 189 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(fragment) = r.fragmentrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`RmrRef<'v, 'm>`]fragment().() { |
| 190 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('#'); |
| 191 | encode_non_ascii_strrust-analyzer cargo fluent-uri 0.4.1 convert/encode_non_ascii_str().(&mut buf, fragment.as_strrust-analyzer cargo fluent-uri 0.4.1 pct_enc/impl#[`EStr<E>`]as_str().()); |
| 192 | } |
| 193 | |
| 194 | debug_assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/debug_assert_eq!!(buf.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().(), len); |
| 195 | |
| 196 | (buf, meta) |
| 197 | } |
| 198 | |
| 199 | #[cfg(feature = "alloc")] |
| 200 | fn encode_non_ascii_strrust-analyzer cargo fluent-uri 0.4.1 convert/encode_non_ascii_str().(buf: &mut Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, s: &str) { |
| 201 | if s.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_ascii().() { |
| 202 | buf.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(s); |
| 203 | } else { |
| 204 | let mut iter = s.char_indicesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]char_indices().(); |
| 205 | while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((start, ch)) = iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/iter/impl#[`CharIndices<'a>`][Iterator]next().() { |
| 206 | if ch.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_ascii().() { |
| 207 | buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(ch); |
| 208 | } else { |
| 209 | // `CharIndices::offset` sadly requires an MSRV of 1.82, |
| 210 | // so we do pointer math to get the offset for now. |
| 211 | let end = 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().s.as_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_ptr().() as usize; |
| 212 | for &x in &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().start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). { |
| 213 | buf.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(pct_encrust-analyzer cargo fluent-uri 0.4.1 pct_enc/::encode_byterust-analyzer cargo fluent-uri 0.4.1 pct_enc/encode_byte().(x)); |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | } |