File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## Unreleased
4+
5+ #### 🚀 Updates
6+
7+ - Implement ` Schematic ` for ` Cow ` .
8+
39## 0.19.5
410
511#### 🚀 Updates
Original file line number Diff line number Diff line change 11#![ allow( dead_code, deprecated) ]
22
33use schematic:: Schematic ;
4+ use std:: borrow:: Cow ;
45use std:: collections:: HashMap ;
56
67#[ derive( Schematic ) ]
@@ -12,6 +13,7 @@ struct Basic<'a> {
1213struct Multiple < ' a , ' b > {
1314 pub name : & ' a str ,
1415 pub age : & ' b u32 ,
16+ pub other : Cow < ' a , str > ,
1517}
1618
1719#[ derive( Schematic ) ]
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ pub use structs::*;
2727pub use tuples:: * ;
2828pub use unions:: * ;
2929
30+ use std:: borrow:: Cow ;
3031use std:: rc:: Rc ;
3132use std:: sync:: Arc ;
3233
@@ -83,6 +84,12 @@ impl<T: Schematic> Schematic for Arc<T> {
8384 }
8485}
8586
87+ impl < T : Schematic + ToOwned + ?Sized > Schematic for Cow < ' _ , T > {
88+ fn build_schema ( schema : SchemaBuilder ) -> Schema {
89+ T :: build_schema ( schema)
90+ }
91+ }
92+
8693impl < T : Schematic > Schematic for Option < T > {
8794 fn build_schema ( mut schema : SchemaBuilder ) -> Schema {
8895 schema. union ( UnionType :: new_any ( [ schema. infer :: < T > ( ) , Schema :: null ( ) ] ) )
You can’t perform that action at this time.
0 commit comments