-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add trait bound ToString to Cell::new()/Cell::new_align() #94
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #94 +/- ##
==========================================
+ Coverage 84.05% 84.13% +0.08%
==========================================
Files 5 5
Lines 1179 1179
==========================================
+ Hits 991 992 +1
+ Misses 188 187 -1
Continue to review full report at Codecov.
|
If I want to construct a fn pretty_matrix(matrix: [[u8; 16]; 16]) -> Table {
let mut table = Table::new();
matrix.iter().for_each(|line| {
table.add_row(Row::new(
line.iter().map(|x| Cell::new(&x.to_string())).collect::<Vec<_>>(),
));
});
table
} Now, the code becomes: fn pretty_matrix(matrix: [[u8; 16]; 16]) -> Table {
let mut table = Table::new();
matrix.iter().for_each(|line| {
table.add_row(Row::new(
line.iter().map(|x| Cell::new(x)).collect::<Vec<_>>(),
));
});
table
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems legit. Thanks
@phsym ping |
@iosmanthus |
After adding trait bound
ToString
toCell::new()/Cell::new_align()
, maybe it will be more convenient to construct a row from another type because it will be unnecessary to transform the content to&str
explicitly.