Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Remove serde_yaml::to_vec #291

Merged
merged 1 commit into from Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -161,7 +161,7 @@

pub use crate::de::{from_reader, from_slice, from_str, Deserializer};
pub use crate::error::{Error, Location, Result};
pub use crate::ser::{to_string, to_vec, to_writer, Serializer};
pub use crate::ser::{to_string, to_writer, Serializer};
#[doc(inline)]
pub use crate::value::{from_value, to_value, Index, Number, Sequence, Value};

Expand Down
16 changes: 2 additions & 14 deletions src/ser.rs
Expand Up @@ -727,19 +727,6 @@ where
value.serialize(&mut serializer)
}

/// Serialize the given data structure as a YAML byte vector.
///
/// Serialization can fail if `T`'s implementation of `Serialize` decides to
/// return an error.
pub fn to_vec<T>(value: &T) -> Result<Vec<u8>>
where
T: ?Sized + ser::Serialize,
{
let mut vec = Vec::with_capacity(128);
to_writer(&mut vec, value)?;
Ok(vec)
}

/// Serialize the given data structure as a String of YAML.
///
/// Serialization can fail if `T`'s implementation of `Serialize` decides to
Expand All @@ -748,6 +735,7 @@ pub fn to_string<T>(value: &T) -> Result<String>
where
T: ?Sized + ser::Serialize,
{
let vec = to_vec(value)?;
let mut vec = Vec::with_capacity(128);
to_writer(&mut vec, value)?;
String::from_utf8(vec).map_err(|error| error::new(ErrorImpl::FromUtf8(error)))
}