Respect fmt trait and flags in Value #400

Merged
KodrAus merged 3 commits from fix/value-fmt into master 2020-06-05 06:21:45 -05:00
KodrAus commented 2020-06-04 06:18:08 -05:00 (Migrated from github.com)

Fixes #395

This PR makes the fmt::Debug and fmt::Display impls on Value respect the trait being used and any flags present. I've added a separate visitor for Display that uses the right trait, and pass the value directly to the formatter instead of going through format_args.

There are some extra tests for formatting and I've shifted a few pieces around to be consistent. Tests won't pass until I fix https://github.com/sval-rs/sval/issues/84 as well.

r? @yoshuawuyts

Fixes #395 This PR makes the `fmt::Debug` and `fmt::Display` impls on `Value` respect the trait being used and any flags present. I've added a separate visitor for `Display` that uses the right trait, and pass the value directly to the formatter instead of going through `format_args`. There are some extra tests for formatting and I've shifted a few pieces around to be consistent. ~~Tests won't pass until I fix https://github.com/sval-rs/sval/issues/84 as well.~~ r? @yoshuawuyts
KodrAus (Migrated from github.com) reviewed 2020-06-04 06:18:46 -05:00
KodrAus (Migrated from github.com) commented 2020-06-04 06:18:46 -05:00

This doesn't pass yet.

This doesn't pass yet.
KodrAus (Migrated from github.com) reviewed 2020-06-04 06:19:09 -05:00
@ -194,0 +198,4 @@
impl sval::Value for TestSval {
fn stream(&self, stream: &mut sval::value::Stream) -> sval::value::Result {
stream.u64(42)
KodrAus (Migrated from github.com) commented 2020-06-04 06:19:09 -05:00

Just moved up into the impl block, like the visitors in the fmt module.

Just moved up into the `impl` block, like the visitors in the `fmt` module.
KodrAus (Migrated from github.com) reviewed 2020-06-04 07:31:38 -05:00
@ -73,4 +70,1 @@
io::Error::new(io::ErrorKind::Other, err)
}
}
}
KodrAus (Migrated from github.com) commented 2020-06-04 07:31:37 -05:00

We removed a similar external From impl in #398 that was causing problems with inference.

We removed a similar external `From` impl in #398 that was causing problems with inference.
yoshuawuyts (Migrated from github.com) approved these changes 2020-06-05 05:43:57 -05:00
yoshuawuyts (Migrated from github.com) left a comment

💯 -- thanks heaps!

:100: -- thanks heaps!
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-rust-lang/log!400
No description provided.