fix clippy feedbacks and format code
This commit is contained in:
@@ -12,17 +12,18 @@ pub fn to_string<T: YaSerialize>(model: &T) -> Result<String, String> {
|
||||
Ok(String::from(data))
|
||||
}
|
||||
|
||||
pub fn to_string_with_config<T: YaSerialize>(
|
||||
model: &T,
|
||||
config: &Config,
|
||||
) -> Result<String, String> {
|
||||
pub fn to_string_with_config<T: YaSerialize>(model: &T, config: &Config) -> Result<String, String> {
|
||||
let buf = Cursor::new(Vec::new());
|
||||
let cursor = serialize_with_writer(model, buf, config)?;
|
||||
let data = str::from_utf8(cursor.get_ref()).expect("Found invalid UTF-8");
|
||||
Ok(String::from(data))
|
||||
}
|
||||
|
||||
pub fn serialize_with_writer<W: Write, T: YaSerialize>(model: &T, writer: W, _config: &Config) -> Result<W, String> {
|
||||
pub fn serialize_with_writer<W: Write, T: YaSerialize>(
|
||||
model: &T,
|
||||
writer: W,
|
||||
_config: &Config,
|
||||
) -> Result<W, String> {
|
||||
let mut serializer = Serializer::new_from_writer(writer);
|
||||
match model.serialize(&mut serializer) {
|
||||
Ok(()) => Ok(serializer.into_inner()),
|
||||
@@ -112,10 +113,10 @@ pub struct Config {
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Config{
|
||||
Config {
|
||||
perform_indent: false,
|
||||
write_document_declaration: true,
|
||||
indent_string: None
|
||||
indent_string: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user