| 1 | use superrust-analyzer cargo mediatype 0.23.0 crate/::parserust-analyzer cargo mediatype 0.23.0 parse/::*; |
| 2 | use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::{borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#, fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, 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#, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/}; |
| 3 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{ |
| 4 | 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#, |
| 5 | 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#, Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#}, |
| 6 | iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/, |
| 7 | }; |
| 8 | |
| 9 | /// A media-type parameter value. |
| 10 | /// |
| 11 | /// The constructor accepts both an unquoted string and a quoted string like `"Hello Wold!"`. |
| 12 | /// If the string is not quoted, the allowed characters are |
| 13 | /// alphabets, numbers and `!#$&-^_.+%*'`. |
| 14 | /// |
| 15 | /// ``` |
| 16 | /// # use mediatype::Value; |
| 17 | /// let utf8 = Value::new("UTF-8").unwrap(); |
| 18 | /// let utf8_quoted = Value::new("\"UTF-8\"").unwrap(); |
| 19 | /// assert_eq!(utf8, utf8_quoted); |
| 20 | /// assert_eq!(utf8_quoted.as_str(), "\"UTF-8\""); |
| 21 | /// assert_eq!(utf8_quoted.unquoted_str(), "UTF-8"); |
| 22 | /// |
| 23 | /// let double_quoted = Value::new("\" \\\" \"").unwrap(); |
| 24 | /// assert_eq!(double_quoted.as_str(), "\" \\\" \""); |
| 25 | /// assert_eq!(double_quoted.unquoted_str(), " \" "); |
| 26 | /// ``` |
| 27 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 28 | pub struct Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'a>(&'a str); |
| 29 | |
| 30 | impl<'a> Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'a> { |
| 31 | /// Constructs a `Value`. |
| 32 | /// |
| 33 | /// If the string is not valid as a value, returns `None`. |
| 34 | #[must_use] |
| 35 | pub fn newrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]new().(s: &'a str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]> { |
| 36 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(quoted) = s.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().('\"') { |
| 37 | if quoted.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 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().1 && parse_quoted_valuerust-analyzer cargo mediatype 0.23.0 parse/parse_quoted_value().(quoted) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][`PartialEq<Self>`]eq().Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoted.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()) { |
| 38 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Selfrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`](s)); |
| 39 | } |
| 40 | } else if is_restricted_strrust-analyzer cargo mediatype 0.23.0 parse/is_restricted_str().(s) { |
| 41 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Selfrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`](s)); |
| 42 | } |
| 43 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 44 | } |
| 45 | |
| 46 | /// Returns the underlying string. |
| 47 | #[must_use] |
| 48 | pub const fn as_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]as_str().(&self) -> &'a str { |
| 49 | self.0rust-analyzer cargo mediatype 0.23.0 value/Value#0. |
| 50 | } |
| 51 | |
| 52 | /// Returns the unquoted string. |
| 53 | #[must_use] |
| 54 | pub fn unquoted_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]unquoted_str().(&self) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str> { |
| 55 | if self.0rust-analyzer cargo mediatype 0.23.0 value/Value#0..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('"') { |
| 56 | let inner = &self.0rust-analyzer cargo mediatype 0.23.0 value/Value#0.[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/range/Range#self.0rust-analyzer cargo mediatype 0.23.0 value/Value#0..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().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 57 | if inner.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('\\') { |
| 58 | let mut s = 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().(inner.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().()); |
| 59 | let mut quoted = false; |
| 60 | for c in inner.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().() { |
| 61 | match c { |
| 62 | _ if quoted => { |
| 63 | quoted = false; |
| 64 | s.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(c); |
| 65 | } |
| 66 | '\\' => { |
| 67 | quoted = true; |
| 68 | } |
| 69 | _ => { |
| 70 | s.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(c); |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | 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#(s) |
| 75 | } else { |
| 76 | 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#(inner) |
| 77 | } |
| 78 | } else { |
| 79 | 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#(self.0rust-analyzer cargo mediatype 0.23.0 value/Value#0.) |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /// Generates a quoted string if necessary. |
| 84 | /// |
| 85 | /// ``` |
| 86 | /// # use mediatype::Value; |
| 87 | /// assert_eq!(Value::quote("UTF-8"), "UTF-8"); |
| 88 | /// assert_eq!(Value::quote("Hello world!"), "\"Hello world!\""); |
| 89 | /// assert_eq!( |
| 90 | /// Value::quote(r#" "What's wrong?" "#), |
| 91 | /// "\" \\\"What's wrong\\?\\\" \"" |
| 92 | /// ); |
| 93 | /// ``` |
| 94 | #[must_use] |
| 95 | pub fn quoterust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]quote().(s: &str) -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str> { |
| 96 | if is_restricted_strrust-analyzer cargo mediatype 0.23.0 parse/is_restricted_str().(s) { |
| 97 | 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) |
| 98 | } else { |
| 99 | let inner = s.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|c| { |
| 100 | if is_restricted_charrust-analyzer cargo mediatype 0.23.0 parse/is_restricted_char().(c) || c rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().' ' { |
| 101 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![c] |
| 102 | } else { |
| 103 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!['\\', c] |
| 104 | } |
| 105 | }); |
| 106 | let quoted = iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().('"').chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(inner).chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().('"')); |
| 107 | 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#(quoted.collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()) |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | pub(craterust-analyzer cargo mediatype 0.23.0 crate/) const fn new_uncheckedrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]new_unchecked().(s: &'a str) -> Selfrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`] { |
| 112 | Selfrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`](s) |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 117 | fn fmtrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 118 | f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(self.0rust-analyzer cargo mediatype 0.23.0 value/Value#0.) |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 123 | fn eqrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<Self>`]eq().(&self, other: &Selfrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<Self>`]) -> bool { |
| 124 | self.unquoted_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]unquoted_str().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'a, B>`][`PartialEq<Cow<'b, C>>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'a, B>`][`PartialEq<Cow<'b, C>>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'a, B>`][`PartialEq<Cow<'b, C>>`]eq().other.unquoted_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]unquoted_str().() |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | impl Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> {} |
| 129 | |
| 130 | impl PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 131 | fn partial_cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialOrd<Self>`]partial_cmp().(&self, other: &Selfrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`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#> { |
| 132 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][Ord]cmp().(other)) |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | impl Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 137 | fn cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][Ord]cmp().(&self, other: &Selfrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][Ord]) -> Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# { |
| 138 | self.unquoted_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]unquoted_str().().cmprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, B>`][Ord]cmp().(&other.unquoted_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]unquoted_str().()) |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | impl Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash# for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 143 | fn hashrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][Hash]hash().<H: Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#>(&self, state: &mut H) { |
| 144 | self.unquoted_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]unquoted_str().().hashrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, B>`][Hash]hash().(state); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 149 | fn eqrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<String>`]eq().(&self, other: &Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> bool { |
| 150 | self.eqrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<str>`]eq().(other.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | impl PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 155 | fn partial_cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialOrd<String>`]partial_cmp().(&self, other: &Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> 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#> { |
| 156 | self.partial_cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialOrd<str>`]partial_cmp().(other.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<&Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 161 | fn eqrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<&String>`]eq().(&self, other: &&Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> bool { |
| 162 | self.eqrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<str>`]eq().(other.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | impl PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#<&Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 167 | fn partial_cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialOrd<&String>`]partial_cmp().(&self, other: &&Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> 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#> { |
| 168 | self.partial_cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialOrd<str>`]partial_cmp().(other.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().()) |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<str> for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 173 | fn eqrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<str>`]eq().(&self, other: &str) -> bool { |
| 174 | self.unquoted_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]unquoted_str().() rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`Cow<'_, str>`][`PartialEq<&str>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`Cow<'_, str>`][`PartialEq<&str>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[`Cow<'_, str>`][`PartialEq<&str>`]eq().other |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | impl PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#<str> for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 179 | fn partial_cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialOrd<str>`]partial_cmp().(&self, other: &str) -> 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#> { |
| 180 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.unquoted_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]unquoted_str().().as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().().cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/impl#[str][Ord]cmp().(other)) |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<&str> for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 185 | fn eqrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<&str>`]eq().(&self, other: &&str) -> bool { |
| 186 | self.eqrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<str>`]eq().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().other) |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | impl PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#<&str> for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 191 | fn partial_cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialOrd<&str>`]partial_cmp().(&self, other: &&str) -> 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#> { |
| 192 | self.partial_cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialOrd<str>`]partial_cmp().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().other) |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str>> for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 197 | fn eqrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<Cow<'_, str>>`]eq().(&self, other: &Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str>) -> bool { |
| 198 | self.eqrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<str>`]eq().(other.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().()) |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | impl PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#<Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str>> for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 203 | fn partial_cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialOrd<Cow<'_, str>>`]partial_cmp().(&self, other: &Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str>) -> 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#> { |
| 204 | self.partial_cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialOrd<str>`]partial_cmp().(other.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().()) |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#<&Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str>> for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 209 | fn eqrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<&Cow<'_, str>>`]eq().(&self, other: &&Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str>) -> bool { |
| 210 | self.eqrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialEq<str>`]eq().(other.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`&T`][`AsRef<U>`]as_ref().()) |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | impl PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#<&Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str>> for Valuerust-analyzer cargo mediatype 0.23.0 value/Value#<'_> { |
| 215 | fn partial_cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialOrd<&Cow<'_, str>>`]partial_cmp().(&self, other: &&Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str>) -> 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#> { |
| 216 | self.partial_cmprust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'_>`][`PartialOrd<str>`]partial_cmp().(other.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`&T`][`AsRef<U>`]as_ref().()) |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | #[cfg(test)] |
| 221 | mod testsrust-analyzer cargo mediatype 0.23.0 value/tests/ { |
| 222 | use superrust-analyzer cargo mediatype 0.23.0 value/::*; |
| 223 | |
| 224 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 225 | fn unquoted_strrust-analyzer cargo mediatype 0.23.0 value/tests/unquoted_str().() { |
| 226 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Valuerust-analyzer cargo mediatype 0.23.0 value/Value#::newrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]new().("\"\\a\\\\\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unquoted_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]unquoted_str().(), "a\\"); |
| 227 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Valuerust-analyzer cargo mediatype 0.23.0 value/Value#::newrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]new().("\"\\\"\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unquoted_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]unquoted_str().(), "\""); |
| 228 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Valuerust-analyzer cargo mediatype 0.23.0 value/Value#::newrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]new().("\"\\a\\b\\c\"").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().unquoted_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]unquoted_str().(), "abc"); |
| 229 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 230 | Valuerust-analyzer cargo mediatype 0.23.0 value/Value#::newrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]new().("\" \\\"What's wrong\\?\\\" \"") |
| 231 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 232 | .unquoted_strrust-analyzer cargo mediatype 0.23.0 value/impl#[`Value<'a>`]unquoted_str().(), |
| 233 | r#" "What's wrong?" "# |
| 234 | ); |
| 235 | } |
| 236 | } |