| 1 | use craterust-analyzer cargo schemars 1.2.2 crate/::preluderust-analyzer cargo schemars 1.2.2 prelude/::*; |
| 2 | 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#; |
| 3 | |
| 4 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 5 | struct MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator#; |
| 6 | |
| 7 | impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator# { |
| 8 | type Itemrust-analyzer cargo schemars 1.2.2 bound/impl#[MyIterator][Iterator]Item# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#; |
| 9 | |
| 10 | fn nextrust-analyzer cargo schemars 1.2.2 bound/impl#[MyIterator][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo schemars 1.2.2 bound/impl#[MyIterator][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 11 | unimplementedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unimplemented!!() |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | // The default trait bounds would require T/U to implement JsonSchema, which MyIterator does not. |
| 16 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 17 | #[schemars(bound = "T::Item: JsonSchema")] |
| 18 | pub struct MyContainerrust-analyzer cargo schemars 1.2.2 bound/MyContainer#<T, U> |
| 19 | where |
| 20 | T: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 21 | U: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 22 | { |
| 23 | pub associatedrust-analyzer cargo schemars 1.2.2 bound/MyContainer#associated.: T::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#, |
| 24 | #[schemarsrust-analyzer cargo schemars_derive 1.2.2 schemars:(bound = "U::Item: JsonSchema")] |
| 25 | pub associated2rust-analyzer cargo schemars 1.2.2 bound/MyContainer#associated2.: U::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#, |
| 26 | pub phantomrust-analyzer cargo schemars 1.2.2 bound/MyContainer#phantom.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<T>, |
| 27 | #[serderust-analyzer cargo schemars_derive 1.2.2 serde:(skip)] |
| 28 | pub _skippedrust-analyzer cargo schemars 1.2.2 bound/MyContainer#_skipped.: T, |
| 29 | } |
| 30 | |
| 31 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 32 | fn manual_bound_setrust-analyzer cargo schemars 1.2.2 bound/manual_bound_set().() { |
| 33 | testrust-analyzer cargo schemars 1.2.2 test!!(MyContainerrust-analyzer cargo schemars 1.2.2 bound/MyContainer#<MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator#, MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator#>) |
| 34 | // TODO with better bounds, this assertion would work: |
| 35 | // .assert_identical::<MyContainer<core::slice::Iter<&str>>>() |
| 36 | .assert_snapshotrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_snapshot().() |
| 37 | .assert_allows_ser_roundtrip_defaultrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip_default().() |
| 38 | .assert_allows_ser_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip().([MyContainerrust-analyzer cargo schemars 1.2.2 bound/MyContainer# { |
| 39 | associatedrust-analyzer cargo schemars 1.2.2 bound/MyContainer#associated.: "test".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 40 | associated2rust-analyzer cargo schemars 1.2.2 bound/MyContainer#associated2.: "test".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(), |
| 41 | phantomrust-analyzer cargo schemars 1.2.2 bound/MyContainer#phantom.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 42 | _skippedrust-analyzer cargo schemars 1.2.2 bound/MyContainer#_skipped.: MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator#, |
| 43 | }]) |
| 44 | .assert_matches_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_matches_de_roundtrip().(arbitrary_valuesrust-analyzer cargo schemars 1.2.2 test_helper/arbitrary_values().()); |
| 45 | |
| 46 | assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!( |
| 47 | <MyContainerrust-analyzer cargo schemars 1.2.2 bound/MyContainer#<MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator#, MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator#>>::schema_idrust-analyzer cargo schemars 1.2.2 bound/impl#[`MyContainer<T, U>`][JsonSchema]schema_id().(), |
| 48 | <MyContainerrust-analyzer cargo schemars 1.2.2 bound/MyContainer#<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/::Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<i32>, MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator#>>::schema_idrust-analyzer cargo schemars 1.2.2 bound/impl#[`MyContainer<T, U>`][JsonSchema]schema_id().() |
| 49 | ); |
| 50 | assert_nerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_ne!!( |
| 51 | <MyContainerrust-analyzer cargo schemars 1.2.2 bound/MyContainer#<MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator#, MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator#>>::schema_idrust-analyzer cargo schemars 1.2.2 bound/impl#[`MyContainer<T, U>`][JsonSchema]schema_id().(), |
| 52 | <MyContainerrust-analyzer cargo schemars 1.2.2 bound/MyContainer#<MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator#, 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/::Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<i32>>>::schema_idrust-analyzer cargo schemars 1.2.2 bound/impl#[`MyContainer<T, U>`][JsonSchema]schema_id().() |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | // `T` doesn't need to impl `JsonSchema`, but `U` does |
| 57 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(JsonSchemarust-analyzer cargo schemars_derive 1.2.2 JsonSchema:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 58 | pub struct MyContainer2rust-analyzer cargo schemars 1.2.2 bound/MyContainer2#<T, U> |
| 59 | where |
| 60 | T: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#, |
| 61 | { |
| 62 | pub urust-analyzer cargo schemars 1.2.2 bound/MyContainer2#u.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<U>, |
| 63 | pub phantomrust-analyzer cargo schemars 1.2.2 bound/MyContainer2#phantom.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<T>, |
| 64 | #[serderust-analyzer cargo schemars_derive 1.2.2 serde:(skip)] |
| 65 | pub _skippedrust-analyzer cargo schemars 1.2.2 bound/MyContainer2#_skipped.: T, |
| 66 | } |
| 67 | |
| 68 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 69 | fn auto_boundrust-analyzer cargo schemars 1.2.2 bound/auto_bound().() { |
| 70 | testrust-analyzer cargo schemars 1.2.2 test!!(MyContainer2rust-analyzer cargo schemars 1.2.2 bound/MyContainer2#<MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>) |
| 71 | .assert_identicalrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_identical().::<MyContainer2rust-analyzer cargo schemars 1.2.2 bound/MyContainer2#<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/::Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<&str>, Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<str>>>() |
| 72 | .assert_snapshotrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_snapshot().() |
| 73 | .assert_allows_ser_roundtrip_defaultrust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip_default().() |
| 74 | .assert_allows_ser_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_allows_ser_roundtrip().([MyContainer2rust-analyzer cargo schemars 1.2.2 bound/MyContainer2# { |
| 75 | urust-analyzer cargo schemars 1.2.2 bound/MyContainer2#u.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("test".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()), |
| 76 | phantomrust-analyzer cargo schemars 1.2.2 bound/MyContainer2#phantom.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 77 | _skippedrust-analyzer cargo schemars 1.2.2 bound/MyContainer2#_skipped.: MyIteratorrust-analyzer cargo schemars 1.2.2 bound/MyIterator#, |
| 78 | }]) |
| 79 | .assert_matches_de_roundtriprust-analyzer cargo schemars 1.2.2 test_helper/impl#[`TestHelper<T>`]assert_matches_de_roundtrip().(arbitrary_valuesrust-analyzer cargo schemars 1.2.2 test_helper/arbitrary_values().()); |
| 80 | } |