fix clippy feedbacks and format code

This commit is contained in:
Marc-Antoine Arnaud
2019-10-08 10:19:50 +02:00
parent 943abf4296
commit 2b701262ac
2 changed files with 57 additions and 122 deletions

View File

@@ -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,
}
}
}