@@ -20,7 +20,7 @@ use std::
2020#[  test ]  
2121fn  iterator_over_optional_cow ( ) 
2222{ 
23-   use  test_object_without_impl :: TestObjectWithoutImpl  as  TestObjectWithoutImpl ; 
23+   use  the_module :: TestObjectWithoutImpl  as  TestObjectWithoutImpl ; 
2424  use  the_module:: 
2525  { 
2626    Fields , 
@@ -30,90 +30,59 @@ fn iterator_over_optional_cow()
3030    OptionalCow , 
3131  } ; 
3232
33-   // xxx : that should fail 
34-   impl  TableWithFields  for  TestObjectWithoutImpl  { } 
35- 
36-   impl  Fields <  & ' _  str ,  Option <  Cow <  ' _ ,  str  >  >  > 
37-   for  TestObjectWithoutImpl 
38-   { 
39-     type  Key <  ' k  >  = & ' k  str ; 
40-     type  Val <  ' v  >  = Option <  Cow <  ' v ,  str  >  > ; 
41- 
42-     fn  fields (  & self  )  -> impl  IteratorTrait <  Item  = (  & ' _  str ,  Option <  Cow <  ' _ ,  str  >  >  )  > 
43-     { 
44-       use  format_tools:: ref_or_display_or_debug_multiline:: field; 
45-       // use format_tools::ref_or_display_or_debug::field; 
46-       let  mut  dst :  Vec <  (  & ' _  str ,  Option <  Cow <  ' _ ,  str  >  >  )  >  = Vec :: new ( ) ; 
47- 
48-       dst. push (  field ! (  & self . id )  ) ; 
49-       dst. push (  field ! (  & self . created_at )  ) ; 
50-       dst. push (  field ! (  & self . file_ids )  ) ; 
51- 
52-       if  let  Some (  tools )  = & self . tools 
53-       { 
54-         dst. push (  field ! (  tools )  ) ; 
55-       } 
56-       else 
57-       { 
58-         dst. push (  (  "tools" ,  Option :: None  )  ) ; 
59-       } 
60- 
61-       dst. into_iter ( ) 
62-     } 
63- 
64-   } 
65- 
66-   let  data :  collection_tools:: Vec <  TestObjectWithoutImpl  >  = dlist ! 
67-   { 
68-     TestObjectWithoutImpl 
69-     { 
70-       id :  "1" . to_string( ) , 
71-       created_at :  1627845583 , 
72-       file_ids :  vec![  "file1" . to_string( ) ,  "file2" . to_string( )  ] , 
73-       tools :  None 
74-     } , 
75-     TestObjectWithoutImpl 
76-     { 
77-       id :  "2" . to_string( ) , 
78-       created_at :  13 , 
79-       file_ids :  vec![  "file3" . to_string( ) ,  "file4\n more details" . to_string( )  ] , 
80-       tools :  Some 
81-       ( 
82-         vec!
83-         [ 
84-           { 
85-             let  mut  map = HashMap :: new( ) ; 
86-             map. insert(  "tool1" . to_string( ) ,  "value1" . to_string( )  ) ; 
87-             map
88-           } , 
89-           { 
90-             let  mut  map = HashMap :: new( ) ; 
91-             map. insert(  "tool2" . to_string( ) ,  "value2" . to_string( )  ) ; 
92-             map
93-           } 
94-         ] 
95-       ) , 
96-     } , 
97-   } ; 
98- 
99-   use  the_module:: TableFormatter ; 
100-   let  _as_table :  AsTable <  ' _ ,  Vec <  TestObjectWithoutImpl  > ,  & str ,  TestObjectWithoutImpl ,  str >  = AsTable :: new (  & data ) ; 
101-   let  as_table = AsTable :: new (  & data ) ; 
102- 
103-   let  rows = TableRows :: rows (  & as_table ) ; 
104-   assert_eq ! (  rows. len( ) ,  2  ) ; 
33+ //   // xxx : that should fail 
34+ //   impl TableWithFields for TestObjectWithoutImpl {} 
35+ // 
36+ //   impl Fields< &'_ str, Option< Cow< '_, str > > > 
37+ //   for TestObjectWithoutImpl 
38+ //   { 
39+ //     type Key< 'k > = &'k str; 
40+ //     type Val< 'v > = Option< Cow< 'v, str > >; 
41+ // 
42+ //     fn fields( &self ) -> impl IteratorTrait< Item = ( &'_ str, Option< Cow< '_, str > > ) > 
43+ //     { 
44+ //       use format_tools::ref_or_display_or_debug_multiline::field; 
45+ //       // use format_tools::ref_or_display_or_debug::field; 
46+ //       let mut dst : Vec< ( &'_ str, Option< Cow< '_, str > > ) > = Vec::new(); 
47+ // 
48+ //       dst.push( field!( &self.id ) ); 
49+ //       dst.push( field!( &self.created_at ) ); 
50+ //       dst.push( field!( &self.file_ids ) ); 
51+ // 
52+ //       if let Some( tools ) = &self.tools 
53+ //       { 
54+ //         dst.push( field!( tools ) ); 
55+ //       } 
56+ //       else 
57+ //       { 
58+ //         dst.push( ( "tools", Option::None ) ); 
59+ //       } 
60+ // 
61+ //       dst.into_iter() 
62+ //     } 
63+ // 
64+ //   } 
10565
106-   let  mut  output = String :: new ( ) ; 
107-   let  mut  context = the_module:: print:: Context :: new (  & mut  output,  Default :: default ( )  ) ; 
108-   let  _got = the_module:: TableFormatter :: fmt (  & as_table,  & mut  context ) ; 
109-   let  got = as_table. table_to_string ( ) ; 
110-   assert ! (  got. contains(  "│ id │ created_at │          file_ids          │           tools            │"  )  ) ; 
111-   assert ! (  got. contains(  "│     13     │ [                          │ [                          │"  )  ) ; 
112-   assert ! (  got. contains(  "│ 1627845583 │        [                   │                            │"  )  ) ; 
66+   let  data :  collection_tools:: Vec <  TestObjectWithoutImpl  >  = the_module:: test_objects_gen ( ) ; 
11367
114-   let  got = AsTable :: new (  & data ) . table_to_string ( ) ; 
115-   assert ! (  got. contains(  "│ id │ created_at │          file_ids          │           tools            │"  )  ) ; 
116-   assert ! (  got. contains(  "│     13     │ [                          │ [                          │"  )  ) ; 
117-   assert ! (  got. contains(  "│ 1627845583 │        [                   │                            │"  )  ) ; 
68+ //   use the_module::TableFormatter; 
69+ //   let _as_table : AsTable< '_, Vec< TestObjectWithoutImpl >, &str, TestObjectWithoutImpl, str> = AsTable::new( &data ); 
70+ //   let as_table = AsTable::new( &data ); 
71+ // 
72+ //   let rows = TableRows::rows( &as_table ); 
73+ //   assert_eq!( rows.len(), 2 ); 
74+ // 
75+ //   let mut output = String::new(); 
76+ //   let mut context = the_module::print::Context::new( &mut output, Default::default() ); 
77+ //   let _got = the_module::TableFormatter::fmt( &as_table, &mut context ); 
78+ //   let got = as_table.table_to_string(); 
79+ //   assert!( got.contains( "│ id │ created_at │          file_ids          │           tools            │" ) ); 
80+ //   assert!( got.contains( "│     13     │ [                          │ [                          │" ) ); 
81+ //   assert!( got.contains( "│ 1627845583 │        [                   │                            │" ) ); 
82+ // 
83+ //   let got = AsTable::new( &data ).table_to_string(); 
84+ //   assert!( got.contains( "│ id │ created_at │          file_ids          │           tools            │" ) ); 
85+ //   assert!( got.contains( "│     13     │ [                          │ [                          │" ) ); 
86+ //   assert!( got.contains( "│ 1627845583 │        [                   │                            │" ) ); 
11887
11988} 
0 commit comments