| 1 | use craterust-analyzer cargo schemars 1.2.2 crate/::SchemaGeneratorrust-analyzer cargo schemars 1.2.2 generate/SchemaGenerator#; |
| 2 | use craterust-analyzer cargo schemars 1.2.2 crate/::_alloc_preluderust-analyzer cargo schemars 1.2.2 _alloc_prelude/::*; |
| 3 | use craterust-analyzer cargo schemars 1.2.2 crate/::{json_schemarust-analyzer cargo schemars 1.2.2 macros/json_schema!, JsonSchemarust-analyzer cargo schemars 1.2.2 JsonSchema#, Schemarust-analyzer cargo schemars 1.2.2 schema/Schema#}; |
| 4 | 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#; |
| 5 | |
| 6 | // Does not require T: JsonSchema. |
| 7 | impl<T> JsonSchemarust-analyzer cargo schemars 1.2.2 JsonSchema# for [T; 0] { |
| 8 | inline_schemarust-analyzer cargo schemars 1.2.2 json_schema_impls/inline_schema!!(); |
| 9 | |
| 10 | fn schema_namerust-analyzer cargo schemars 1.2.2 json_schema_impls/array/impl#[`[T; 0]`][JsonSchema]schema_name().() -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str> { |
| 11 | "EmptyArray".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 12 | } |
| 13 | |
| 14 | fn schema_idrust-analyzer cargo schemars 1.2.2 json_schema_impls/array/impl#[`[T; 0]`][JsonSchema]schema_id().() -> Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'static, str> { |
| 15 | "[]".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() |
| 16 | } |
| 17 | |
| 18 | fn json_schemarust-analyzer cargo schemars 1.2.2 json_schema_impls/array/impl#[`[T; 0]`][JsonSchema]json_schema().(_: &mut SchemaGeneratorrust-analyzer cargo schemars 1.2.2 generate/SchemaGenerator#) -> Schemarust-analyzer cargo schemars 1.2.2 schema/Schema# { |
| 19 | json_schemarust-analyzer cargo schemars 1.2.2 macros/json_schema!!({ |
| 20 | "type": "array", |
| 21 | "maxItems": 0, |
| 22 | }) |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | macro_rules! array_implsrust-analyzer cargo schemars 1.2.2 json_schema_impls/array/array_impls! { |
| 27 | ($($len:tt)+) => { |
| 28 | $( |
| 29 | impl<T: JsonSchema> JsonSchema for [T; $len] { |
| 30 | inline_schema!(); |
| 31 | |
| 32 | fn schema_name() -> Cow<'static, str> { |
| 33 | format!("Array_size_{}_of_{}", $len, T::schema_name()).into() |
| 34 | } |
| 35 | |
| 36 | fn schema_id() -> Cow<'static, str> { |
| 37 | format!("[{}; {}]", $len, T::schema_id()).into() |
| 38 | } |
| 39 | |
| 40 | fn json_schema(generator: &mut SchemaGenerator) -> Schema { |
| 41 | json_schema!({ |
| 42 | "type": "array", |
| 43 | "items": serde_json::Value::from(generator.subschema_for::<T>()), |
| 44 | "minItems": $len, |
| 45 | "maxItems": $len, |
| 46 | }) |
| 47 | } |
| 48 | } |
| 49 | )+ |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | array_implsrust-analyzer cargo schemars 1.2.2 json_schema_impls/array/array_impls!! { |
| 54 | 1 2 3 4 5 6 7 8 9 10 |
| 55 | 11 12 13 14 15 16 17 18 19 20 |
| 56 | 21 22 23 24 25 26 27 28 29 30 |
| 57 | 31 32 |
| 58 | } |