Debian Codegraph @

src/specification/subresources.rs

raw symbols SCIP
1 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/;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::FlatMaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/flatten/FlatMap#;
3
4 use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#;
5
6 use craterust-analyzer cargo referencing 0.37.4 crate/::{resourcerust-analyzer cargo referencing 0.37.4 resource/::InnerResourcePtrrust-analyzer cargo referencing 0.37.4 resource/InnerResourcePtr#, segmentsrust-analyzer cargo referencing 0.37.4 segments/::Segmentrust-analyzer cargo referencing 0.37.4 segments/Segment#, Errorrust-analyzer cargo referencing 0.37.4 error/Error#, Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#, Segmentsrust-analyzer cargo referencing 0.37.4 segments/Segments#};
7
8 type ObjectIterrust-analyzer cargo referencing 0.37.4 specification/subresources/ObjectIter#<'a> = FlatMaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/flatten/FlatMap#<
9 serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::maprust-analyzer cargo serde_json 1.0.145 map/::Iterrust-analyzer cargo serde_json 1.0.145 map/Iter#<'a>,
10 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#<'a>,
11 fn((&'a stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std 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#, &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#)) -> SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#<'a>,
12 >;
13
14 /// A simple iterator that either wraps an iterator producing &Value or is empty.
15 /// NOTE: It is noticeably slower if `Object` is boxed.
16 #[allow(clippy::large_enum_variant)]
17 pub(craterust-analyzer cargo referencing 0.37.4 crate/) enum SubresourceIteratorrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#<'a> {
18 Objectrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#Object#(ObjectIterrust-analyzer cargo referencing 0.37.4 specification/subresources/ObjectIter#<'a>),
19 Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#Empty#,
20 }
21
22 impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for SubresourceIteratorrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#<'a> {
23 type Itemrust-analyzer cargo referencing 0.37.4 specification/subresources/impl#[`SubresourceIterator<'a>`][Iterator]Item# = &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#;
24 fn nextrust-analyzer cargo referencing 0.37.4 specification/subresources/impl#[`SubresourceIterator<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo referencing 0.37.4 specification/subresources/impl#[`SubresourceIterator<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
25 match self {
26 SubresourceIteratorrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#::Objectrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#Object#(iter) => iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/flatten/impl#[`FlatMap<I, U, F>`][Iterator]next().(),
27 SubresourceIteratorrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#Empty# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
28 }
29 }
30 }
31
32 pub(craterust-analyzer cargo referencing 0.37.4 crate/) enum SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#<'a> {
33 Oncerust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Once#(&'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#),
34 Arrayrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Array#(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, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>),
35 Objectrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Object#(serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::maprust-analyzer cargo serde_json 1.0.145 map/::Valuesrust-analyzer cargo serde_json 1.0.145 map/Values#<'a>),
36 FilteredObjectrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#FilteredObject#(serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::maprust-analyzer cargo serde_json 1.0.145 map/::Valuesrust-analyzer cargo serde_json 1.0.145 map/Values#<'a>),
37 Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty#,
38 }
39
40 impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#<'a> {
41 type Itemrust-analyzer cargo referencing 0.37.4 specification/subresources/impl#[`SubresourceIteratorInner<'a>`][Iterator]Item# = &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#;
42 fn nextrust-analyzer cargo referencing 0.37.4 specification/subresources/impl#[`SubresourceIteratorInner<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo referencing 0.37.4 specification/subresources/impl#[`SubresourceIteratorInner<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
43 match self {
44 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Oncerust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Once#(_) => {
45 let SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Oncerust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Once#(value) =
46 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/replace().(self, SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty#)
47 else {
48 unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!()
49 };
50 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value)
51 }
52 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Arrayrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Array#(iter) => iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().(),
53 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Objectrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Object#(iter) => iter.nextrust-analyzer cargo serde_json 1.0.145 map/impl#[`Values<'a>`][Iterator]next().(),
54 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::FilteredObjectrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#FilteredObject#(iter) => {
55 for next in iter.by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().() {
56 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().next.is_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]is_object().() {
57 continue;
58 }
59 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(next);
60 }
61 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
62 }
63 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
64 }
65 }
66 }
67
68 pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn object_iterrust-analyzer cargo referencing 0.37.4 specification/subresources/object_iter().<'a>(
69 (key, value): (&'a Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#),
70 ) -> SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#<'a> {
71 match key.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() {
72 "additionalProperties"
73 | "contains"
74 | "contentSchema"
75 | "else"
76 | "if"
77 | "items"
78 | "not"
79 | "propertyNames"
80 | "then"
81 | "unevaluatedItems"
82 | "unevaluatedProperties" => SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Oncerust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Once#(value),
83 "allOf" | "anyOf" | "oneOf" | "prefixItems" => {
84 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(arr) = value.as_arrayrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_array().() {
85 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Arrayrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Array#(arr.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().())
86 } else {
87 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty#
88 }
89 }
90 "$defs" | "definitions" | "dependentSchemas" | "patternProperties" | "properties" => {
91 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(obj) = value.as_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_object().() {
92 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Objectrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Object#(obj.valuesrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]values().())
93 } else {
94 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty#
95 }
96 }
97 _ => SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty#,
98 }
99 }
100
101 pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn maybe_in_subresourcerust-analyzer cargo referencing 0.37.4 specification/subresources/maybe_in_subresource().<'r>(
102 segments: &Segmentsrust-analyzer cargo referencing 0.37.4 segments/Segments#,
103 resolver: &Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r>,
104 subresource: &InnerResourcePtrrust-analyzer cargo referencing 0.37.4 resource/InnerResourcePtr#,
105 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r>, Errorrust-analyzer cargo referencing 0.37.4 error/Error#> {
106 const IN_VALUErust-analyzer cargo referencing 0.37.4 specification/subresources/IN_VALUE.: &[&str] = &[
107 "additionalProperties",
108 "contains",
109 "contentSchema",
110 "else",
111 "if",
112 "items",
113 "not",
114 "propertyNames",
115 "then",
116 "unevaluatedItems",
117 "unevaluatedProperties",
118 ];
119 const IN_CHILDrust-analyzer cargo referencing 0.37.4 specification/subresources/IN_CHILD.: &[&str] = &[
120 "allOf",
121 "anyOf",
122 "oneOf",
123 "prefixItems",
124 "$defs",
125 "definitions",
126 "dependentSchemas",
127 "patternProperties",
128 "properties",
129 ];
130
131 let mut iter = segments.iterrust-analyzer cargo referencing 0.37.4 segments/impl#[`Segments<'a>`]iter().();
132 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(segment) = iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().() {
133 if let Segmentrust-analyzer cargo referencing 0.37.4 segments/Segment#::Keyrust-analyzer cargo referencing 0.37.4 segments/Segment#Key#(key) = segment {
134 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().IN_VALUErust-analyzer cargo referencing 0.37.4 specification/subresources/IN_VALUE..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&key.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().())
135 && (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().IN_CHILDrust-analyzer cargo referencing 0.37.4 specification/subresources/IN_CHILD..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&key.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().()) || iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().())
136 {
137 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(resolver.clonerust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`][Clone]clone().());
138 }
139 }
140 }
141 resolver.in_subresource_innerrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]in_subresource_inner().(subresource)
142 }
143
144 #[inline]
145 pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn maybe_in_subresource_with_items_and_dependenciesrust-analyzer cargo referencing 0.37.4 specification/subresources/maybe_in_subresource_with_items_and_dependencies().<'r>(
146 segments: &Segmentsrust-analyzer cargo referencing 0.37.4 segments/Segments#,
147 resolver: &Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r>,
148 subresource: &InnerResourcePtrrust-analyzer cargo referencing 0.37.4 resource/InnerResourcePtr#,
149 in_value: &[&str],
150 in_child: &[&str],
151 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r>, Errorrust-analyzer cargo referencing 0.37.4 error/Error#> {
152 let mut iter = segments.iterrust-analyzer cargo referencing 0.37.4 segments/impl#[`Segments<'a>`]iter().();
153 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(segment) = iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().() {
154 if let Segmentrust-analyzer cargo referencing 0.37.4 segments/Segment#::Keyrust-analyzer cargo referencing 0.37.4 segments/Segment#Key#(key) = segment {
155 if (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().key 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()."items" || *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().key 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()."dependencies") && subresource.contentsrust-analyzer cargo referencing 0.37.4 resource/impl#[InnerResourcePtr]contents().().is_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]is_object().() {
156 return resolver.in_subresource_innerrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]in_subresource_inner().(subresource);
157 }
158 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().in_value.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&key.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().())
159 && (!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().in_child.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&key.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[`Cow<'_, T>`][`AsRef<T>`]as_ref().()) || iter.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().())
160 {
161 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(resolver.clonerust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`][Clone]clone().());
162 }
163 }
164 }
165 resolver.in_subresource_innerrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]in_subresource_inner().(subresource)
166 }
167
168 #[cfg(test)]
169 mod testsrust-analyzer cargo referencing 0.37.4 specification/subresources/tests/ {
170 use craterust-analyzer cargo referencing 0.37.4 crate/::Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#;
171
172 use superrust-analyzer cargo referencing 0.37.4 specification/subresources/::{object_iterrust-analyzer cargo referencing 0.37.4 specification/subresources/object_iter()., SubresourceIteratorrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#};
173 use ahashrust-analyzer cargo ahash 0.8.12 crate/::HashSetrust-analyzer cargo ahash 0.8.12 HashSet#;
174 use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::{jsonrust-analyzer cargo serde_json 1.0.145 macros/json!, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#};
175 use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:;
176
177 pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn subresources_ofrust-analyzer cargo referencing 0.37.4 specification/subresources/tests/subresources_of().(contents: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> SubresourceIteratorrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#<'_> {
178 match contents.as_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_object().() {
179 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(schema) => SubresourceIteratorrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#::Objectrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#Object#(schema.iterrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]iter().().flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(object_iterrust-analyzer cargo referencing 0.37.4 specification/subresources/object_iter().)),
180 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => SubresourceIteratorrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIterator#Empty#,
181 }
182 }
183
184 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(true), &[] ; "boolean schema")]
185 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(false), &[] ; "boolean schema false")]
186 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({}), &[] ; "empty object")]
187 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "string"}), &[] ; "no subresources")]
188 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(
189 &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"additionalProperties": {"type": "string"}}),
190 &[jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "string"})] ;
191 "in_value single"
192 )]
193 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(
194 &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"if": {"type": "string"}, "then": {"minimum": 0}}),
195 &[jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "string"}), jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"minimum": 0})] ;
196 "in_value multiple"
197 )]
198 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(
199 &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"properties": {"foo": {"type": "string"}, "bar": {"type": "number"}}}),
200 &[jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "string"}), jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "number"})] ;
201 "in_subvalues"
202 )]
203 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(
204 &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"allOf": [{"type": "string"}, {"minLength": 1}]}),
205 &[jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "string"}), jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"minLength": 1})] ;
206 "in_subarray"
207 )]
208 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(
209 &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({
210 "type": "object",
211 "properties": {
212 "foo": {"type": "string"},
213 "bar": {"type": "number"}
214 },
215 "additionalProperties": {"type": "boolean"},
216 "allOf": [
217 {"required": ["foo"]},
218 {"required": ["bar"]}
219 ]
220 }),
221 &[
222 jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "string"}),
223 jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "number"}),
224 jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "boolean"}),
225 jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"required": ["foo"]}),
226 jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"required": ["bar"]})
227 ] ;
228 "complex schema"
229 )]
230 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(
231 &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({
232 "$defs": {
233 "positiveInteger": {
234 "type": "integer",
235 "exclusiveMinimum": 0
236 }
237 },
238 "properties": {
239 "count": { "$ref": "#/$defs/positiveInteger" }
240 }
241 }),
242 &[
243 jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "integer", "exclusiveMinimum": 0}),
244 jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"$ref": "#/$defs/positiveInteger"})
245 ] ;
246 "with $defs"
247 )]
248 fn test_subresources_ofrust-analyzer cargo referencing 0.37.4 specification/subresources/tests/test_subresources_of().(schema: &serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, expected: &[serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#]) {
249 let subresources: HashSetrust-analyzer cargo ahash 0.8.12 HashSet#<&serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#> = subresources_ofrust-analyzer cargo referencing 0.37.4 specification/subresources/tests/subresources_of().(schema).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
250 let expected_set: HashSetrust-analyzer cargo ahash 0.8.12 HashSet#<&serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#> = expected.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
251
252 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
253 subresources.lenrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]len().(),
254 expected.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(),
255 "Number of subresources doesn't match"
256 );
257 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
258 subresources, expected_set,
259 "Subresources don't match expected values"
260 );
261 }
262
263 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
264 fn test_all_keywordsrust-analyzer cargo referencing 0.37.4 specification/subresources/tests/test_all_keywords().() {
265 let schema = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({
266 "additionalProperties": {"type": "string"},
267 "contains": {"minimum": 0},
268 "contentSchema": {"format": "email"},
269 "else": {"maximum": 100},
270 "if": {"type": "number"},
271 "items": {"type": "array"},
272 "not": {"type": "null"},
273 "propertyNames": {"minLength": 1},
274 "then": {"multipleOf": 2},
275 "unevaluatedItems": {"type": "boolean"},
276 "unevaluatedProperties": {"type": "integer"},
277 "allOf": [{"type": "object"}, {"required": ["foo"]}],
278 "anyOf": [{"minimum": 0}, {"maximum": 100}],
279 "oneOf": [{"type": "string"}, {"type": "number"}],
280 "prefixItems": [{"type": "string"}, {"type": "number"}],
281 "$defs": {
282 "positiveInteger": {"type": "integer", "minimum": 1}
283 },
284 "definitions": {
285 "negativeInteger": {"type": "integer", "maximum": -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1}
286 },
287 "dependentSchemas": {
288 "foo": {"required": ["bar"]}
289 },
290 "patternProperties": {
291 "^S_": {"type": "string"},
292 "^I_": {"type": "integer"}
293 },
294 "properties": {
295 "prop1": {"type": "string"},
296 "prop2": {"type": "number"}
297 }
298 });
299
300 let subresources: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#> = subresources_ofrust-analyzer cargo referencing 0.37.4 specification/subresources/tests/subresources_of().(&schema).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
301 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(subresources.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 26);
302
303 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "string"})));
304 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"minimum": 0})));
305 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"format": "email"})));
306 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"maximum": 100})));
307 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "number"})));
308 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "array"})));
309 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "null"})));
310 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"minLength": 1})));
311 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"multipleOf": 2})));
312 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "boolean"})));
313 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "integer"})));
314 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "object"})));
315 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"required": ["foo"]})));
316 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"minimum": 0})));
317 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"maximum": 100})));
318 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "string"})));
319 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "number"})));
320 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "integer", "minimum": 1})));
321 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "integer", "maximum": -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1})));
322 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"required": ["bar"]})));
323 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "string"})));
324 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(subresources.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]contains().(&&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"type": "integer"})));
325 }
326
327 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft4rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft4#)]
328 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft6rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft6#)]
329 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft7rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft7#)]
330 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft201909rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft201909#)]
331 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#::Draft202012rust-analyzer cargo referencing 0.37.4 specification/Draft#Draft202012#)]
332 fn test_subresources_of_bool_schemarust-analyzer cargo referencing 0.37.4 specification/subresources/tests/test_subresources_of_bool_schema().(draft: Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#) {
333 let bool_schema = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(true);
334
335 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
336 draft
337 .subresources_ofrust-analyzer cargo referencing 0.37.4 specification/impl#[Draft]subresources_of().(&bool_schema)
338 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()
339 .is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().(),
340 "Draft {draft:?} should return empty subresources for boolean schema",
341 );
342 }
343 }