Debian Codegraph @

src/serde_impl.rs

raw symbols SCIP
1 // Copyright (c) 2020 Nikita Pekin and the lazycell contributors
2 // See the README.md file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.use serde::ser::{Serialize, Serializer};
9 use serderust-analyzer cargo serde 1.0.229 crate/::serrust-analyzer cargo serde_core 1.0.229 ser/::{Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize#, Serializerrust-analyzer cargo serde_core 1.0.229 ser/Serializer#};
10 use serderust-analyzer cargo serde 1.0.229 crate/::derust-analyzer cargo serde_core 1.0.229 de/::{selfrust-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#, Visitorrust-analyzer cargo serde_core 1.0.229 de/Visitor#};
11
12 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/;
13 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::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#;
14
15 use superrust-analyzer cargo lazycell 1.3.0 crate/::{LazyCellrust-analyzer cargo lazycell 1.3.0 LazyCell#, AtomicLazyCellrust-analyzer cargo lazycell 1.3.0 AtomicLazyCell#};
16
17 impl<T: Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize#> Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize# for LazyCellrust-analyzer cargo lazycell 1.3.0 LazyCell#<T> {
18 fn serializerust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`LazyCell<T>`][Serialize]serialize().<S: Serializerrust-analyzer cargo serde_core 1.0.229 ser/Serializer#>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Error#> {
19 match self.borrowrust-analyzer cargo lazycell 1.3.0 impl#[`LazyCell<T>`]borrow().() {
20 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val) => serializer.serialize_somerust-analyzer cargo serde_core 1.0.229 ser/Serializer#serialize_some().(val),
21 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => serializer.serialize_nonerust-analyzer cargo serde_core 1.0.229 ser/Serializer#serialize_none().()
22 }
23 }
24 }
25
26
27 impl<T: Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize#> Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize# for AtomicLazyCellrust-analyzer cargo lazycell 1.3.0 AtomicLazyCell#<T> {
28 fn serializerust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`AtomicLazyCell<T>`][Serialize]serialize().<S: Serializerrust-analyzer cargo serde_core 1.0.229 ser/Serializer#>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Error#> {
29 match self.borrowrust-analyzer cargo lazycell 1.3.0 impl#[`AtomicLazyCell<T>`]borrow().() {
30 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val) => serializer.serialize_somerust-analyzer cargo serde_core 1.0.229 ser/Serializer#serialize_some().(val),
31 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => serializer.serialize_nonerust-analyzer cargo serde_core 1.0.229 ser/Serializer#serialize_none().()
32 }
33 }
34 }
35
36 struct LazyCellVisitorrust-analyzer cargo lazycell 1.3.0 serde_impl/LazyCellVisitor#<T>(PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<*const T>);
37 impl<'de, T: Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#<'de>> Visitorrust-analyzer cargo serde_core 1.0.229 de/Visitor#<'de> for LazyCellVisitorrust-analyzer cargo lazycell 1.3.0 serde_impl/LazyCellVisitor#<T> {
38 type Valuerust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`LazyCellVisitor<T>`][`Visitor<'de>`]Value# = LazyCellrust-analyzer cargo lazycell 1.3.0 LazyCell#<T>;
39
40 fn expectingrust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`LazyCellVisitor<T>`][`Visitor<'de>`]expecting().(&self, formatter: &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# {
41 formatter.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("a LazyCell")
42 }
43
44 fn visit_somerust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`LazyCellVisitor<T>`][`Visitor<'de>`]visit_some().<D: Deserializerrust-analyzer cargo serde_core 1.0.229 de/Deserializer#<'de>>(self, deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`LazyCellVisitor<T>`][`Visitor<'de>`]::Valuerust-analyzer cargo serde_core 1.0.229 de/Visitor#Value#, D::Errorrust-analyzer cargo serde_core 1.0.229 de/Deserializer#Error#> {
45 let mut cell = LazyCellrust-analyzer cargo lazycell 1.3.0 LazyCell#::newrust-analyzer cargo lazycell 1.3.0 impl#[`LazyCell<T>`]new().();
46 cell.replacerust-analyzer cargo lazycell 1.3.0 impl#[`LazyCell<T>`]replace().(T::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().);
47 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(cell)
48 }
49
50 fn visit_nonerust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`LazyCellVisitor<T>`][`Visitor<'de>`]visit_none().<E: derust-analyzer cargo serde_core 1.0.229 de/::Errorrust-analyzer cargo serde_core 1.0.229 de/Error#>(self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`LazyCellVisitor<T>`][`Visitor<'de>`]::Valuerust-analyzer cargo serde_core 1.0.229 de/Visitor#Value#, E> {
51 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(LazyCellrust-analyzer cargo lazycell 1.3.0 LazyCell#::newrust-analyzer cargo lazycell 1.3.0 impl#[`LazyCell<T>`]new().())
52 }
53 }
54
55 impl<'de, T: Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#<'de>> Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#<'de> for LazyCellrust-analyzer cargo lazycell 1.3.0 LazyCell#<T> {
56 fn deserializerust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`LazyCell<T>`][`Deserialize<'de>`]deserialize().<D: Deserializerrust-analyzer cargo serde_core 1.0.229 de/Deserializer#<'de>>(deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`LazyCell<T>`][`Deserialize<'de>`], D::Errorrust-analyzer cargo serde_core 1.0.229 de/Deserializer#Error#> {
57 deserializer.deserialize_optionrust-analyzer cargo serde_core 1.0.229 de/Deserializer#deserialize_option().(LazyCellVisitorrust-analyzer cargo lazycell 1.3.0 serde_impl/LazyCellVisitor#(PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#))
58 }
59 }
60
61
62 struct AtomicLazyCellVisitorrust-analyzer cargo lazycell 1.3.0 serde_impl/AtomicLazyCellVisitor#<T>(PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<*const T>);
63 impl<'de, T: Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#<'de>> Visitorrust-analyzer cargo serde_core 1.0.229 de/Visitor#<'de> for AtomicLazyCellVisitorrust-analyzer cargo lazycell 1.3.0 serde_impl/AtomicLazyCellVisitor#<T> {
64 type Valuerust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`AtomicLazyCellVisitor<T>`][`Visitor<'de>`]Value# = AtomicLazyCellrust-analyzer cargo lazycell 1.3.0 AtomicLazyCell#<T>;
65
66 fn expectingrust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`AtomicLazyCellVisitor<T>`][`Visitor<'de>`]expecting().(&self, formatter: &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# {
67 formatter.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("an AtomicLazyCell")
68 }
69
70 fn visit_somerust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`AtomicLazyCellVisitor<T>`][`Visitor<'de>`]visit_some().<D: Deserializerrust-analyzer cargo serde_core 1.0.229 de/Deserializer#<'de>>(self, deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`AtomicLazyCellVisitor<T>`][`Visitor<'de>`]::Valuerust-analyzer cargo serde_core 1.0.229 de/Visitor#Value#, D::Errorrust-analyzer cargo serde_core 1.0.229 de/Deserializer#Error#> {
71 let mut cell = AtomicLazyCellrust-analyzer cargo lazycell 1.3.0 AtomicLazyCell#::newrust-analyzer cargo lazycell 1.3.0 impl#[`AtomicLazyCell<T>`]new().();
72 cell.replacerust-analyzer cargo lazycell 1.3.0 impl#[`AtomicLazyCell<T>`]replace().(T::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().);
73 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(cell)
74 }
75
76 fn visit_nonerust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`AtomicLazyCellVisitor<T>`][`Visitor<'de>`]visit_none().<E: derust-analyzer cargo serde_core 1.0.229 de/::Errorrust-analyzer cargo serde_core 1.0.229 de/Error#>(self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`AtomicLazyCellVisitor<T>`][`Visitor<'de>`]::Valuerust-analyzer cargo serde_core 1.0.229 de/Visitor#Value#, E> {
77 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(AtomicLazyCellrust-analyzer cargo lazycell 1.3.0 AtomicLazyCell#::newrust-analyzer cargo lazycell 1.3.0 impl#[`AtomicLazyCell<T>`]new().())
78 }
79 }
80
81
82 impl<'de, T: Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#<'de>> Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#<'de> for AtomicLazyCellrust-analyzer cargo lazycell 1.3.0 AtomicLazyCell#<T> {
83 fn deserializerust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`AtomicLazyCell<T>`][`Deserialize<'de>`]deserialize().<D: Deserializerrust-analyzer cargo serde_core 1.0.229 de/Deserializer#<'de>>(deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo lazycell 1.3.0 serde_impl/impl#[`AtomicLazyCell<T>`][`Deserialize<'de>`], D::Errorrust-analyzer cargo serde_core 1.0.229 de/Deserializer#Error#> {
84 deserializer.deserialize_optionrust-analyzer cargo serde_core 1.0.229 de/Deserializer#deserialize_option().(AtomicLazyCellVisitorrust-analyzer cargo lazycell 1.3.0 serde_impl/AtomicLazyCellVisitor#(PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#))
85 }
86 }