diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2022-02-14 11:24:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-14 11:24:33 +0100 |
commit | 53d79c91e6bf90e0986fa8f4a8a2597daec26b79 (patch) | |
tree | 1406bf53a28da8bee95bf1ffcf43a6dc14baa7ec | |
parent | 379ea3fcdaccf2aec01b24d16c485d4bcabd9a58 (diff) | |
parent | e4a572d253253c951a3af570802f7058fd1ab3a9 (diff) |
Merge pull request #864 from matthiasbeyer/clippy-fixes-json_writer
Clippy fixes for: json_writer
-rw-r--r-- | crates/common/json_writer/src/lib.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/common/json_writer/src/lib.rs b/crates/common/json_writer/src/lib.rs index 2bd4541d..df92765b 100644 --- a/crates/common/json_writer/src/lib.rs +++ b/crates/common/json_writer/src/lib.rs @@ -21,14 +21,17 @@ pub enum JsonWriterError { InvalidF64Value { value: f64 }, } -impl JsonWriter { - pub fn new() -> Self { +#[cfg(test)] +impl Default for JsonWriter { + fn default() -> Self { Self { buffer: Vec::new(), needs_separator: false, } } +} +impl JsonWriter { pub fn with_capacity(capacity: usize) -> Self { Self { buffer: Vec::with_capacity(capacity), @@ -93,7 +96,7 @@ mod tests { #[test] fn write_empty_message() -> anyhow::Result<()> { - let mut jw = JsonWriter::new(); + let mut jw = JsonWriter::default(); jw.write_open_obj(); jw.write_close_obj(); assert_eq!(jw.into_string()?, "{}"); @@ -102,7 +105,7 @@ mod tests { #[test] fn write_invalid_f64_message() -> anyhow::Result<()> { - let mut jw = JsonWriter::new(); + let mut jw = JsonWriter::default(); let value = 1.0 / 0.0; let error = jw.write_f64(value).unwrap_err(); assert_eq!(error.to_string(), "Invalid f64 value inf"); |