Debian Codegraph @

src/path.rs

raw symbols SCIP
1 use superrust-analyzer cargo serde_path_to_error 0.1.20 crate/::Chainrust-analyzer cargo serde_path_to_error 0.1.20 Chain#;
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/::ToOwnedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/ToOwned# as _;
3 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#;
4 use allocrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc crate/::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#;
5 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::{selfrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#};
6 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/;
7
8 /// Path to the error value in the input, like `dependencies.serde.typo1`.
9 ///
10 /// Use `path.to_string()` to get a string representation of the path with
11 /// segments separated by periods, or use `path.iter()` to iterate over
12 /// individual segments of the path.
13 #[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:)]
14 pub struct Pathrust-analyzer cargo serde_path_to_error 0.1.20 path/Path# {
15 segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Path#segments.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#>,
16 }
17
18 /// Single segment of a path.
19 #[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:)]
20 pub enum Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment# {
21 Seqrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Seq# { indexrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Seq#index.: usize },
22 Maprust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Map# { keyrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Map#key.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# },
23 Enumrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Enum# { variantrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Enum#variant.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# },
24 Unknownrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Unknown#,
25 }
26
27 impl Pathrust-analyzer cargo serde_path_to_error 0.1.20 path/Path# {
28 /// Returns an iterator with element type [`&Segment`][Segment].
29 pub fn iterrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[Path]iter().(&self) -> Segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments# {
30 Segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments# {
31 iterrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments#iter.: self.segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Path#segments..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(),
32 }
33 }
34 }
35
36 impl<'a> IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator# for &'a Pathrust-analyzer cargo serde_path_to_error 0.1.20 path/Path# {
37 type Itemrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[`&'a Path`][IntoIterator]Item# = &'a Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#;
38 type IntoIterrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[`&'a Path`][IntoIterator]IntoIter# = Segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments#<'a>;
39
40 fn into_iterrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[`&'a Path`][IntoIterator]into_iter().(self) -> Selfrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[`&'a Path`][IntoIterator]::IntoIterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#IntoIter# {
41 self.iterrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[Path]iter().()
42 }
43 }
44
45 /// Iterator over segments of a path.
46 pub struct Segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments#<'a> {
47 iterrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments#iter.: slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/::Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<'a, Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#>,
48 }
49
50 impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for Segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments#<'a> {
51 type Itemrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[`Segments<'a>`][Iterator]Item# = &'a Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#;
52
53 fn nextrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[`Segments<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[`Segments<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
54 self.iterrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments#iter..nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().()
55 }
56
57 fn size_hintrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[`Segments<'a>`][Iterator]size_hint().(&self) -> (usize, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<usize>) {
58 self.iterrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments#iter..size_hintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]size_hint().()
59 }
60 }
61
62 impl<'a> DoubleEndedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/double_ended/DoubleEndedIterator# for Segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments#<'a> {
63 fn next_backrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[`Segments<'a>`][DoubleEndedIterator]next_back().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[`Segments<'a>`][DoubleEndedIterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
64 self.iterrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments#iter..next_backrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][DoubleEndedIterator]next_back().()
65 }
66 }
67
68 impl<'a> ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator# for Segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments#<'a> {
69 fn lenrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[`Segments<'a>`][ExactSizeIterator]len().(&self) -> usize {
70 self.iterrust-analyzer cargo serde_path_to_error 0.1.20 path/Segments#iter..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'_, T>`][ExactSizeIterator]len().()
71 }
72 }
73
74 impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Pathrust-analyzer cargo serde_path_to_error 0.1.20 path/Path# {
75 fn fmtrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[Path][Display]fmt().(&self, formatter: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
76 if self.segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Path#segments..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
77 return formatter.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(".");
78 }
79
80 let mut separator = "";
81 for segment in self {
82 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(segment, Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#::Seqrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Seq# { .. }) {
83 formatter.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(separator)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
84 }
85 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(formatter, "{}", segment)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
86 separator = ".";
87 }
88
89 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
90 }
91 }
92
93 impl Pathrust-analyzer cargo serde_path_to_error 0.1.20 path/Path# {
94 pub(craterust-analyzer cargo serde_path_to_error 0.1.20 crate/) fn emptyrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[Path]empty().() -> Selfrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[Path] {
95 Pathrust-analyzer cargo serde_path_to_error 0.1.20 path/Path# {
96 segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Path#segments.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(),
97 }
98 }
99
100 pub(craterust-analyzer cargo serde_path_to_error 0.1.20 crate/) fn from_chainrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[Path]from_chain().(mut chain: &Chainrust-analyzer cargo serde_path_to_error 0.1.20 Chain#) -> Selfrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[Path] {
101 let mut segments = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
102 loop {
103 match chain {
104 Chainrust-analyzer cargo serde_path_to_error 0.1.20 Chain#::Rootrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Root# => break,
105 Chainrust-analyzer cargo serde_path_to_error 0.1.20 Chain#::Seqrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Seq# { parentrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Seq#parent., indexrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Seq#index. } => {
106 segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#::Seqrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Seq# { indexrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Seq#index.: *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().index });
107 chain = parent;
108 }
109 Chainrust-analyzer cargo serde_path_to_error 0.1.20 Chain#::Maprust-analyzer cargo serde_path_to_error 0.1.20 Chain#Map# { parentrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Map#parent., keyrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Map#key. } => {
110 segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#::Maprust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Map# { keyrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Map#key.: key.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().() });
111 chain = parent;
112 }
113 Chainrust-analyzer cargo serde_path_to_error 0.1.20 Chain#::Structrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Struct# { parentrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Struct#parent., keyrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Struct#key. } => {
114 let key = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().key;
115 segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#::Maprust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Map# {
116 keyrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Map#key.: key.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(),
117 });
118 chain = parent;
119 }
120 Chainrust-analyzer cargo serde_path_to_error 0.1.20 Chain#::Enumrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Enum# { parentrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Enum#parent., variantrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Enum#variant. } => {
121 segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#::Enumrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Enum# {
122 variantrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Enum#variant.: variant.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(),
123 });
124 chain = parent;
125 }
126 Chainrust-analyzer cargo serde_path_to_error 0.1.20 Chain#::Somerust-analyzer cargo serde_path_to_error 0.1.20 Chain#Some# { parentrust-analyzer cargo serde_path_to_error 0.1.20 Chain#Some#parent. }
127 | Chainrust-analyzer cargo serde_path_to_error 0.1.20 Chain#::NewtypeStructrust-analyzer cargo serde_path_to_error 0.1.20 Chain#NewtypeStruct# { parentrust-analyzer cargo serde_path_to_error 0.1.20 Chain#NewtypeStruct#parent. }
128 | Chainrust-analyzer cargo serde_path_to_error 0.1.20 Chain#::NewtypeVariantrust-analyzer cargo serde_path_to_error 0.1.20 Chain#NewtypeVariant# { parentrust-analyzer cargo serde_path_to_error 0.1.20 Chain#NewtypeVariant#parent. } => {
129 chain = parent;
130 }
131 Chainrust-analyzer cargo serde_path_to_error 0.1.20 Chain#::NonStringKeyrust-analyzer cargo serde_path_to_error 0.1.20 Chain#NonStringKey# { parentrust-analyzer cargo serde_path_to_error 0.1.20 Chain#NonStringKey#parent. } => {
132 segments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#::Unknownrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Unknown#);
133 chain = parent;
134 }
135 }
136 }
137 segments.reverserust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]reverse().();
138 Pathrust-analyzer cargo serde_path_to_error 0.1.20 path/Path# { segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Path#segments. }
139 }
140
141 pub(craterust-analyzer cargo serde_path_to_error 0.1.20 crate/) fn is_only_unknownrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[Path]is_only_unknown().(&self) -> bool {
142 self.segmentsrust-analyzer cargo serde_path_to_error 0.1.20 path/Path#segments..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#::is_unknownrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[Segment]is_unknown().)
143 }
144 }
145
146 impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment# {
147 fn fmtrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[Segment][Display]fmt().(&self, formatter: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
148 match self {
149 Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#::Seqrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Seq# { indexrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Seq#index. } => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(formatter, "[{}]", index),
150 Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#::Maprust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Map# { keyrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Map#key. } | Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#::Enumrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Enum# { variantrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Enum#variant.: key } => {
151 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(formatter, "{}", key)
152 }
153 Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#::Unknownrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Unknown# => formatter.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("?"),
154 }
155 }
156 }
157
158 impl Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment# {
159 fn is_unknownrust-analyzer cargo serde_path_to_error 0.1.20 path/impl#[Segment]is_unknown().(&self) -> bool {
160 matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Segmentrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#::Unknownrust-analyzer cargo serde_path_to_error 0.1.20 path/Segment#Unknown#)
161 }
162 }