mirror of
https://gitee.com/openharmony/third_party_rust_log
synced 2024-11-22 23:29:49 +00:00
Clean up trailing whitespace
This commit is contained in:
parent
cd690d1607
commit
41193b9223
@ -338,12 +338,12 @@ fn log_record(w: impl Write, r: &Record) -> io::Result<()> {
|
||||
record
|
||||
.key_values()
|
||||
.for_each(|k, v| writeln!("{}: {}", k, v))?;
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
In the above example, the `Source::for_each` method iterates over each key-value pair in the `Source` and writes them to the output stream.
|
||||
In the above example, the `Source::for_each` method iterates over each key-value pair in the `Source` and writes them to the output stream.
|
||||
|
||||
### Writing key-value pairs as JSON
|
||||
|
||||
@ -509,7 +509,7 @@ Don't create a new serialization API that requires `log` to become a public depe
|
||||
|
||||
### Support arbitrary producers and arbitrary consumers
|
||||
|
||||
Provide an API that's suitable for two independent logging frameworks to integrate through if they want. Producers of structured data and consumers of structured data should be able to use different serialization frameworks opaquely and still get good results. As an example, a producer of a `log::Record` should be able to log a map that implements `sval::Value`, and the implementor of the receiving `Log` trait should be able to format that map using `serde::Serialize`.
|
||||
Provide an API that's suitable for two independent logging frameworks to integrate through if they want. Producers of structured data and consumers of structured data should be able to use different serialization frameworks opaquely and still get good results. As an example, a producer of a `log::Record` should be able to log a map that implements `sval::Value`, and the implementor of the receiving `Log` trait should be able to format that map using `serde::Serialize`.
|
||||
|
||||
### Remain object safe
|
||||
|
||||
@ -709,7 +709,7 @@ impl<'a> FromAny<'a> {
|
||||
fn i128(self, v: i128) -> Result<(), Error> {
|
||||
..
|
||||
}
|
||||
|
||||
|
||||
fn f64(self, v: f64) -> Result<(), Error> {
|
||||
..
|
||||
}
|
||||
|
@ -3,30 +3,30 @@
|
||||
use kv::{Error, Key, ToKey, Value, ToValue};
|
||||
|
||||
/// A source of key-value pairs.
|
||||
///
|
||||
///
|
||||
/// The source may be a single pair, a set of pairs, or a filter over a set of pairs.
|
||||
/// Use the [`Visitor`](trait.Visitor.html) trait to inspect the structured data
|
||||
/// in a source.
|
||||
pub trait Source {
|
||||
/// Visit key-value pairs.
|
||||
///
|
||||
///
|
||||
/// A source doesn't have to guarantee any ordering or uniqueness of key-value pairs.
|
||||
/// If the given visitor returns an error then the source may early-return with it,
|
||||
/// even if there are more key-value pairs.
|
||||
///
|
||||
///
|
||||
/// # Implementation notes
|
||||
///
|
||||
///
|
||||
/// A source should yield the same key-value pairs to a subsequent visitor unless
|
||||
/// that visitor itself fails.
|
||||
fn visit<'kvs>(&'kvs self, visitor: &mut Visitor<'kvs>) -> Result<(), Error>;
|
||||
|
||||
/// Count the number of key-value pairs that can be visited.
|
||||
///
|
||||
///
|
||||
/// # Implementation notes
|
||||
///
|
||||
///
|
||||
/// A source that knows the number of key-value pairs upfront may provide a more
|
||||
/// efficient implementation.
|
||||
///
|
||||
///
|
||||
/// A subsequent call to `visit` should yield the same number of key-value pairs
|
||||
/// to the visitor, unless that visitor fails part way through.
|
||||
fn count(&self) -> usize {
|
||||
|
@ -4,7 +4,7 @@ use super::Error;
|
||||
|
||||
// `Visit` and `Visitor` is an internal API for visiting the structure of a value.
|
||||
// It's not intended to be public (at this stage).
|
||||
//
|
||||
//
|
||||
// Right now we only have an implementation for `std::fmt`, but
|
||||
// this trait makes it possible to add more structured backends like
|
||||
// `serde` that can retain that original structure.
|
||||
|
@ -1648,7 +1648,7 @@ mod tests {
|
||||
let record_test = Record::builder()
|
||||
.key_values(&kvs)
|
||||
.build();
|
||||
|
||||
|
||||
let mut visitor = TestVisitor {
|
||||
seen_pairs: 0,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user