Skip to content

Commit ed72319

Browse files
committed
fixing format_tools
1 parent dc7b822 commit ed72319

File tree

10 files changed

+195
-118
lines changed

10 files changed

+195
-118
lines changed

module/core/format_tools/src/format.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ mod private
2828
{{
2929
(
3030
::core::stringify!( $key ),
31-
$crate::OptionalCow::< '_, str, $how >::from
31+
// $crate::OptionalCow::< '_, str, $how >::from
32+
Option::Some
3233
(
3334
$crate::to_string_with_fallback!( $how, $fallback1, $fallback2, $src )
3435
),

module/core/format_tools/src/format/as_table.rs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,29 @@ mod private
2121
///
2222
#[ repr( transparent ) ]
2323
#[ derive( Clone, Copy ) ]
24-
pub struct AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr >
24+
pub struct AsTable< 'table, Table, RowKey, Row, CellKey>
2525
(
2626
&'table Table,
2727
::core::marker::PhantomData
2828
<(
2929
&'table (),
30-
fn() -> ( &'table RowKey, Row, &'table CellKey, CellRepr ),
30+
fn() -> ( &'table RowKey, Row, &'table CellKey ),
3131
)>,
3232
)
3333
where
3434
RowKey : table::RowKey,
35-
Row : Cells< CellKey, CellRepr >,
35+
Row : Cells< CellKey>,
3636
CellKey : table::CellKey + ?Sized,
37-
CellRepr : table::CellRepr
37+
// CellRepr : table::CellRepr
3838
;
3939

40-
impl< 'table, Table, RowKey, Row, CellKey, CellRepr >
41-
AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr >
40+
impl< 'table, Table, RowKey, Row, CellKey>
41+
AsTable< 'table, Table, RowKey, Row, CellKey>
4242
where
4343
RowKey : table::RowKey,
44-
Row : Cells< CellKey, CellRepr >,
44+
Row : Cells< CellKey>,
4545
CellKey : table::CellKey + ?Sized,
46-
CellRepr : table::CellRepr,
46+
// CellRepr : table::CellRepr,
4747
{
4848
/// Just a constructor.
4949
pub fn new( src : &'table Table ) -> Self
@@ -52,27 +52,27 @@ mod private
5252
}
5353
}
5454

55-
impl< 'table, Table, RowKey, Row, CellKey, CellRepr > AsRef< Table >
56-
for AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr >
55+
impl< 'table, Table, RowKey, Row, CellKey> AsRef< Table >
56+
for AsTable< 'table, Table, RowKey, Row, CellKey>
5757
where
5858
RowKey : table::RowKey,
59-
Row : Cells< CellKey, CellRepr >,
59+
Row : Cells< CellKey>,
6060
CellKey : table::CellKey + ?Sized,
61-
CellRepr : table::CellRepr,
61+
// CellRepr : table::CellRepr,
6262
{
6363
fn as_ref( &self ) -> &Table
6464
{
6565
&self.0
6666
}
6767
}
6868

69-
impl< 'table, Table, RowKey, Row, CellKey, CellRepr > Deref
70-
for AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr >
69+
impl< 'table, Table, RowKey, Row, CellKey> Deref
70+
for AsTable< 'table, Table, RowKey, Row, CellKey>
7171
where
7272
RowKey : table::RowKey,
73-
Row : Cells< CellKey, CellRepr >,
73+
Row : Cells< CellKey>,
7474
CellKey : table::CellKey + ?Sized,
75-
CellRepr : table::CellRepr,
75+
// CellRepr : table::CellRepr,
7676
{
7777
type Target = Table;
7878

@@ -82,28 +82,28 @@ mod private
8282
}
8383
}
8484

85-
impl< 'table, Table, RowKey, Row, CellKey, CellRepr > From< &'table Table >
86-
for AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr >
85+
impl< 'table, Table, RowKey, Row, CellKey> From< &'table Table >
86+
for AsTable< 'table, Table, RowKey, Row, CellKey>
8787
where
8888
RowKey : table::RowKey,
89-
Row : Cells< CellKey, CellRepr >,
89+
Row : Cells< CellKey>,
9090
CellKey : table::CellKey + ?Sized,
91-
CellRepr : table::CellRepr,
91+
// CellRepr : table::CellRepr,
9292
{
9393
fn from( table : &'table Table ) -> Self
9494
{
9595
AsTable( table, PhantomData )
9696
}
9797
}
9898

99-
impl< 'table, Table, RowKey, Row, CellKey, CellRepr > fmt::Debug
100-
for AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr >
99+
impl< 'table, Table, RowKey, Row, CellKey> fmt::Debug
100+
for AsTable< 'table, Table, RowKey, Row, CellKey>
101101
where
102102
Table : fmt::Debug,
103103
RowKey : table::RowKey,
104-
Row : Cells< CellKey, CellRepr >,
104+
Row : Cells< CellKey>,
105105
CellKey : table::CellKey + ?Sized,
106-
CellRepr : table::CellRepr,
106+
// CellRepr : table::CellRepr,
107107
{
108108
fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result
109109
{
@@ -130,35 +130,35 @@ mod private
130130
type RowKey : table::RowKey;
131131

132132
/// The type representing a row, must implement `Cells`.
133-
type Row : Cells< Self::CellKey, Self::CellRepr >;
133+
type Row : Cells< Self::CellKey >;
134134

135135
/// The type used to identify cells within a row, must implement `Key` and can be unsized.
136136
type CellKey : table::CellKey + ?Sized;
137137

138-
/// The type representing the content of a cell, must implement `CellRepr`.
139-
type CellRepr : table::CellRepr;
138+
// /// The type representing the content of a cell, must implement `CellRepr`.
139+
// type // CellRepr : table::CellRepr;
140140

141141
/// Converts the data reference into an `AsTable` reference.
142-
fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey, Self::CellRepr >;
142+
fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey >;
143143
}
144144

145-
impl< 'table, Table, RowKey, Row, CellKey, CellRepr > IntoAsTable
146-
for AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr >
145+
impl< 'table, Table, RowKey, Row, CellKey> IntoAsTable
146+
for AsTable< 'table, Table, RowKey, Row, CellKey>
147147
where
148148
RowKey : table::RowKey,
149-
Row : Cells< CellKey, CellRepr >,
149+
Row : Cells< CellKey>,
150150
CellKey : table::CellKey + ?Sized,
151-
CellRepr : table::CellRepr,
151+
// CellRepr : table::CellRepr,
152152
Self : Copy,
153153
{
154154

155155
type Table = Table;
156156
type RowKey = RowKey;
157157
type Row = Row;
158158
type CellKey = CellKey;
159-
type CellRepr = CellRepr;
159+
// type CellRepr = CellRepr;
160160

161-
fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey, Self::CellRepr >
161+
fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey >
162162
{
163163
*self
164164
}
@@ -168,9 +168,9 @@ mod private
168168
// impl< Row > IntoAsTable
169169
// for Vec< Row >
170170
// where
171-
// Row : Cells< Self::CellKey, Self::CellRepr >,
171+
// Row : Cells< Self::CellKey >,
172172
// // CellKey : table::CellKey + ?Sized,
173-
// // CellRepr : table::CellRepr,
173+
// // // CellRepr : table::CellRepr,
174174
// {
175175
//
176176
// type Table = Self;
@@ -179,14 +179,14 @@ mod private
179179
// type CellKey = str;
180180
// type CellRepr = WithRef;
181181
//
182-
// fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey, Self::CellRepr >
182+
// fn as_table( &self ) -> AsTable< '_, Self::Table, Self::RowKey, Self::Row, Self::CellKey >
183183
// {
184184
// AsTable::from( self )
185185
// }
186186
//
187187
// }
188188

189-
// pub struct AsTable< 'table, Table, RowKey, Row, CellKey, CellRepr >
189+
// pub struct AsTable< 'table, Table, RowKey, Row, CellKey>
190190

191191
}
192192

module/core/format_tools/src/format/print.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,15 @@ mod private
197197
}
198198

199199
/// A trait for formatting tables.
200-
impl< 'data, T, RowKey, Row, CellKey, CellRepr > TableFormatter< 'data >
201-
for AsTable< 'data, T, RowKey, Row, CellKey, CellRepr >
200+
impl< 'data, T, RowKey, Row, CellKey> TableFormatter< 'data >
201+
for AsTable< 'data, T, RowKey, Row, CellKey>
202202
where
203-
Self : TableRows< CellKey = CellKey, CellRepr = CellRepr, RowKey = RowKey, Row = Row >,
203+
Self : TableRows< CellKey = CellKey, RowKey = RowKey, Row = Row >,
204204
Self : TableHeader< CellKey = CellKey >,
205205
RowKey : table::RowKey,
206-
Row : Cells< CellKey, CellRepr >,
206+
Row : Cells< CellKey>,
207207
CellKey : table::CellKey + ?Sized,
208-
CellRepr : table::CellRepr,
208+
// CellRepr : table::CellRepr,
209209
{
210210

211211
fn fmt< 'a >( &'data self, c : &mut Context< 'a > ) -> fmt::Result
@@ -365,7 +365,7 @@ mod private
365365
}
366366
}
367367
/// Extract input data from and collect it in a format consumable by output formatter.
368-
pub fn extract< 't, 'context, Table, RowKey, Row, CellKey, CellRepr >
368+
pub fn extract< 't, 'context, Table, RowKey, Row, CellKey>
369369
(
370370
table : &'t Table,
371371
filter_col : &'context ( dyn FilterCol + 'context ),
@@ -376,12 +376,12 @@ mod private
376376
where
377377
'data : 't,
378378
// 't : 'data,
379-
Table : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey, CellRepr = CellRepr >,
379+
Table : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey >,
380380
Table : TableHeader< CellKey = CellKey >,
381381
RowKey : table::RowKey,
382-
Row : Cells< CellKey, CellRepr > + 'data,
382+
Row : Cells< CellKey> + 'data,
383383
CellKey : table::CellKey + ?Sized + 'data,
384-
CellRepr : table::CellRepr,
384+
// CellRepr : table::CellRepr,
385385
{
386386
use md_math::MdOffset;
387387

@@ -508,7 +508,7 @@ mod private
508508
| ( key, val ) |
509509
{
510510

511-
let val = match val.0
511+
let val = match val
512512
{
513513
Some( val ) =>
514514
{

module/core/format_tools/src/format/table.rs

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod private
1212
// fmt,
1313
borrow::Borrow,
1414
};
15-
// use std::borrow::Cow;
15+
use std::borrow::Cow;
1616
use reflect_tools::
1717
{
1818
IteratorTrait,
@@ -78,35 +78,39 @@ mod private
7878
// =
7979

8080
/// A trait for iterating over all cells of a row.
81-
pub trait Cells< CellKey, CellRepr >
81+
pub trait Cells< CellKey >
8282
where
83-
CellRepr : table::CellRepr,
83+
// CellRepr : table::CellRepr,
8484
CellKey : table::CellKey + ?Sized,
8585
{
8686
/// Returns an iterator over all cells of the row.
87-
fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, OptionalCow< 'b, str, CellRepr > ) >
87+
// fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, OptionalCow< 'b, str > ) >
88+
fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, Option< Cow< 'b, str > > ) >
8889
where
8990
'a : 'b,
9091
CellKey : 'b,
9192
;
9293
}
9394

94-
impl< Row, CellKey, CellRepr > Cells< CellKey, CellRepr >
95+
impl< Row, CellKey > Cells< CellKey >
9596
for Row
9697
where
9798
CellKey : table::CellKey + ?Sized,
9899
for< 'ckv >
99100
Row : TableWithFields + Fields
100101
<
101102
&'ckv CellKey,
102-
OptionalCow< 'ckv, str, CellRepr >,
103+
// OptionalCow< 'ckv, str >,
104+
Option< Cow< 'ckv, str > >,
103105
Key< 'ckv > = &'ckv CellKey,
104-
Val< 'ckv > = OptionalCow< 'ckv, str, CellRepr >,
106+
// Val< 'ckv > = OptionalCow< 'ckv, str >,
107+
Val< 'ckv > = Option< Cow< 'ckv, str > >,
105108
> + 'ckv, // xxx
106-
CellRepr : table::CellRepr,
109+
// CellRepr : table::CellRepr,
107110
{
108111

109-
fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, OptionalCow< 'b, str, CellRepr > ) >
112+
// fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, OptionalCow< 'b, str > ) >
113+
fn cells< 'a, 'b >( &'a self ) -> impl IteratorTrait< Item = ( &'b CellKey, Option< Cow< 'b, str > > ) >
110114
where
111115
'a : 'b,
112116
CellKey : 'b,
@@ -154,15 +158,15 @@ mod private
154158
///
155159
/// The type representing a row, which must implement `Cells`
156160
/// for the specified `CellKey` and `CellRepr`.
157-
type Row : Cells< Self::CellKey, Self::CellRepr >;
161+
type Row : Cells< Self::CellKey >;
158162
///
159163
/// The type used to identify cells within a row, requiring
160164
/// implementation of the `Key` trait.
161165
type CellKey : table::CellKey + ?Sized;
162166
///
163-
/// The type representing the content of a cell, requiring
164-
/// implementation of the `CellRepr` trait.
165-
type CellRepr : table::CellRepr;
167+
// /// The type representing the content of a cell, requiring
168+
// /// implementation of the `CellRepr` trait.
169+
// type // CellRepr : table::CellRepr;
166170

167171
/// Returns an iterator over all rows of the table.
168172
fn rows( &self ) -> impl IteratorTrait< Item = &Self::Row >;
@@ -171,9 +175,9 @@ mod private
171175
// Self::Row : 'a;
172176
}
173177

174-
impl< T, RowKey, Row, CellKey, CellRepr >
178+
impl< T, RowKey, Row, CellKey >
175179
TableRows<>
176-
for AsTable< '_, T, RowKey, Row, CellKey, CellRepr >
180+
for AsTable< '_, T, RowKey, Row, CellKey >
177181
where
178182

179183
for< 'k, 'v > T : Fields
@@ -185,14 +189,14 @@ mod private
185189
> + 'k + 'v,
186190

187191
RowKey : table::RowKey,
188-
Row : TableWithFields + Cells< CellKey, CellRepr >,
192+
Row : TableWithFields + Cells< CellKey >,
189193
CellKey : table::CellKey + ?Sized,
190-
CellRepr : table::CellRepr,
194+
// CellRepr : table::CellRepr,
191195
{
192196
type RowKey = RowKey;
193197
type Row = Row;
194198
type CellKey = CellKey;
195-
type CellRepr = CellRepr;
199+
// type CellRepr = CellRepr;
196200

197201
fn rows( &self ) -> impl IteratorTrait< Item = &Self::Row >
198202
// fn rows< 'a >( &'a self ) -> impl IteratorTrait< Item = &'a Self::Row >
@@ -217,14 +221,14 @@ mod private
217221
// fn mcells( &self ) -> [ usize ; 2 ];
218222
// }
219223
//
220-
// impl< T, RowKey, Row, CellKey, CellRepr > TableSize
221-
// for AsTable< '_, T, RowKey, Row, CellKey, CellRepr >
224+
// impl< T, RowKey, Row, CellKey > TableSize
225+
// for AsTable< '_, T, RowKey, Row, CellKey >
222226
// where
223-
// Self : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey, CellRepr = CellRepr >,
227+
// Self : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey >,
224228
// RowKey : table::RowKey,
225-
// Row : Cells< CellKey, CellRepr >,
229+
// Row : Cells< CellKey >,
226230
// CellKey : table::CellKey + ?Sized,
227-
// CellRepr : table::CellRepr,
231+
// // CellRepr : table::CellRepr,
228232
// {
229233
// fn mcells( &self ) -> [ usize ; 2 ]
230234
// {
@@ -256,14 +260,14 @@ mod private
256260
fn header( &self ) -> Option< impl IteratorTrait< Item = ( &Self::CellKey, &'_ str ) > >;
257261
}
258262

259-
impl< T, RowKey, Row, CellKey, CellRepr > TableHeader
260-
for AsTable< '_, T, RowKey, Row, CellKey, CellRepr >
263+
impl< T, RowKey, Row, CellKey > TableHeader
264+
for AsTable< '_, T, RowKey, Row, CellKey >
261265
where
262-
Self : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey, CellRepr = CellRepr >,
266+
Self : TableRows< RowKey = RowKey, Row = Row, CellKey = CellKey >,
263267
RowKey : table::RowKey,
264-
Row : TableWithFields + Cells< CellKey, CellRepr >,
268+
Row : TableWithFields + Cells< CellKey >,
265269
CellKey : table::CellKey + ?Sized,
266-
CellRepr : table::CellRepr,
270+
// CellRepr : table::CellRepr,
267271
{
268272
type CellKey = CellKey;
269273

0 commit comments

Comments
 (0)