| 1 | use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#; |
| 2 | |
| 3 | use superrust-analyzer cargo bytes-utils 0.1.4 string/::{Storagerust-analyzer cargo bytes-utils 0.1.4 string/Storage#, StrInnerrust-analyzer cargo bytes-utils 0.1.4 string/StrInner#}; |
| 4 | |
| 5 | use serderust-analyzer cargo serde 1.0.229 crate/::derust-analyzer cargo serde_core 1.0.229 de/::{Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#, Deserializerrust-analyzer cargo serde_core 1.0.229 de/Deserializer#, Errorrust-analyzer cargo serde_core 1.0.229 de/Error#, Unexpectedrust-analyzer cargo serde_core 1.0.229 de/Unexpected#}; |
| 6 | use serderust-analyzer cargo serde 1.0.229 crate/::{Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize#, Serializerrust-analyzer cargo serde_core 1.0.229 ser/Serializer#}; |
| 7 | |
| 8 | impl<S: Storagerust-analyzer cargo bytes-utils 0.1.4 string/Storage#> Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize# for StrInnerrust-analyzer cargo bytes-utils 0.1.4 string/StrInner#<S> { |
| 9 | fn serializerust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/impl#[`StrInner<S>`][Serialize]serialize().<Ser>(&self, serializer: Ser) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Ser::Okrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Ok#, Ser::Errorrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Error#> |
| 10 | where |
| 11 | Ser: Serializerrust-analyzer cargo serde_core 1.0.229 ser/Serializer#, |
| 12 | { |
| 13 | let s: &str = Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#::derefrust-analyzer cargo bytes-utils 0.1.4 string/impl#[`StrInner<S>`][Deref]deref().(self); |
| 14 | s.serializerust-analyzer cargo serde_core 1.0.229 ser/impls/impl#[str][Serialize]serialize().(serializer) |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | impl<'de, S: Storagerust-analyzer cargo bytes-utils 0.1.4 string/Storage# + Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#<'de>> Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#<'de> for StrInnerrust-analyzer cargo bytes-utils 0.1.4 string/StrInner#<S> { |
| 19 | fn deserializerust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/impl#[`StrInner<S>`][`Deserialize<'de>`]deserialize().<D>(deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/impl#[`StrInner<S>`][`Deserialize<'de>`], D::Errorrust-analyzer cargo serde_core 1.0.229 de/Deserializer#Error#> |
| 20 | where |
| 21 | D: Deserializerrust-analyzer cargo serde_core 1.0.229 de/Deserializer#<'de>, |
| 22 | { |
| 23 | let inner = <S as Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#>::deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#deserialize().(deserializer)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 24 | Selfrust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/impl#[`StrInner<S>`][`Deserialize<'de>`]::from_innerrust-analyzer cargo bytes-utils 0.1.4 string/impl#[`StrInner<S>`]from_inner().(inner).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|err| { |
| 25 | D::Errorrust-analyzer cargo serde_core 1.0.229 de/Deserializer#Error#::invalid_valuerust-analyzer cargo serde_core 1.0.229 de/Error#invalid_value().( |
| 26 | Unexpectedrust-analyzer cargo serde_core 1.0.229 de/Unexpected#::Bytesrust-analyzer cargo serde_core 1.0.229 de/Unexpected#Bytes#(err.innerrust-analyzer cargo bytes-utils 0.1.4 string/Utf8Error#inner..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().()), |
| 27 | &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Expected utf-8 str: {}", err.erust-analyzer cargo bytes-utils 0.1.4 string/Utf8Error#e.).as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().(), |
| 28 | ) |
| 29 | }) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | #[cfg(test)] |
| 34 | mod testsrust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/tests/ { |
| 35 | use craterust-analyzer cargo bytes-utils 0.1.4 crate/::{Strrust-analyzer cargo bytes-utils 0.1.4 string/Str#, StrMutrust-analyzer cargo bytes-utils 0.1.4 string/StrMut#}; |
| 36 | use serde_testrust-analyzer cargo serde_test 1.0.177 crate/::{assert_tokensrust-analyzer cargo serde_test 1.0.177 assert/assert_tokens()., Tokenrust-analyzer cargo serde_test 1.0.177 token/Token#}; |
| 37 | |
| 38 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 39 | fn test_de_ser_strrust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/tests/test_de_ser_str().() { |
| 40 | const Srust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/tests/S.: &str = "Hello, world!"; |
| 41 | assert_tokensrust-analyzer cargo serde_test 1.0.177 assert/assert_tokens().(&Strrust-analyzer cargo bytes-utils 0.1.4 string/Str#::from_staticrust-analyzer cargo bytes-utils 0.1.4 string/impl#[`StrInner<Bytes>`]from_static().(Srust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/tests/S.), &[Tokenrust-analyzer cargo serde_test 1.0.177 token/Token#::BorrowedStrrust-analyzer cargo serde_test 1.0.177 token/Token#BorrowedStr#(Srust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/tests/S.)]); |
| 42 | } |
| 43 | |
| 44 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 45 | fn test_de_ser_str_mutrust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/tests/test_de_ser_str_mut().() { |
| 46 | const Srust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/tests/S.: &str = "Hello, world!"; |
| 47 | assert_tokensrust-analyzer cargo serde_test 1.0.177 assert/assert_tokens().(&StrMutrust-analyzer cargo bytes-utils 0.1.4 string/StrMut#::fromrust-analyzer cargo bytes-utils 0.1.4 string/impl#[`StrInner<S>`][`From<&'a str>`]from().(Srust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/tests/S.), &[Tokenrust-analyzer cargo serde_test 1.0.177 token/Token#::BorrowedStrrust-analyzer cargo serde_test 1.0.177 token/Token#BorrowedStr#(Srust-analyzer cargo bytes-utils 0.1.4 string/serde_impl/tests/S.)]); |
| 48 | } |
| 49 | } |