-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
107 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
//! Provides pretty serialization with `to_string`. | ||
//! Provides default pretty serialization with `to_string`. | ||
|
||
use super::{Pretty, Result, Serializer}; | ||
use super::{Result, to_string_pretty}; | ||
|
||
use serde::ser::Serialize; | ||
use std::default::Default; | ||
|
||
/// Serializes `value` in the recommended RON layout. | ||
/// Serializes `value` in the recommended RON layout with | ||
/// default pretty configuration. | ||
pub fn to_string<T>(value: &T) -> Result<String> | ||
where T: Serialize | ||
{ | ||
let mut s = Serializer { | ||
output: String::new(), | ||
pretty: Some(Pretty { indent: 0 }), | ||
struct_names: false, | ||
}; | ||
value.serialize(&mut s)?; | ||
Ok(s.output) | ||
to_string_pretty(value, Default::default()) | ||
} |