diff --git a/src/ser.rs b/src/ser.rs index eae9fa3..afae668 100644 --- a/src/ser.rs +++ b/src/ser.rs @@ -691,21 +691,29 @@ impl ser::SerializeMap for NoOp { /// instead of a `List` of `Byte`s: /// /// ``` -/// use self::to_writer; +/// extern crate serde; +/// use nbt::to_writer; +/// use serde::Serialize; /// +/// let mut serialized = Vec::new(); +/// +/// // Declare your struct /// #[derive(Serialize)] /// struct Sheep { -/// #[serde(serialize_with="hematite_nbt::i8_array")] +/// #[serde(serialize_with="nbt::i8_array")] /// byte_data: Vec, /// } /// +/// // Serialize to NBT! /// to_writer( -/// &mut writer, +/// &mut serialized, /// &Sheep { /// byte_data: vec![0x62, 0x69, 0x6E, 0x61, 0x72, 0x79, 0x20, 0x73, 0x68, 0x65, 0x65, 0x70], /// }, /// None -/// )?; +/// ).unwrap(); +/// +/// print!("Serialized: {:?}", serialized); /// ``` pub fn i8_array<'a, T, S>(array: &'a T, serializer: S) -> std::result::Result where @@ -723,21 +731,29 @@ where /// instead of a `List` of `Int`s: /// /// ``` -/// use self::to_writer; +/// extern crate serde; +/// use nbt::to_writer; +/// use serde::Serialize; +/// +/// let mut serialized = Vec::new(); /// +/// // Declare your struct /// #[derive(Serialize)] /// struct Cow { -/// #[serde(serialize_with="hematite_nbt::i32_array")] +/// #[serde(serialize_with="nbt::i32_array")] /// int_data: Vec, /// } /// +/// // Serialize to NBT! /// to_writer( -/// &mut writer, +/// &mut serialized, /// &Cow { /// int_data: vec![1, 8, 64, 512, 4096, 32768, 262144], /// }, /// None -/// )?; +/// ).unwrap(); +/// +/// print!("Serialized: {:?}", serialized); /// ``` pub fn i32_array<'a, T, S>(array: &'a T, serializer: S) -> std::result::Result where @@ -755,21 +771,29 @@ where /// instead of a `List` of `Int`s: /// /// ``` -/// use self::to_writer; +/// extern crate serde; +/// use nbt::to_writer; +/// use serde::Serialize; +/// +/// let mut serialized = Vec::new(); /// +/// // Declare your struct /// #[derive(Serialize)] /// struct Enderman { -/// #[serde(serialize_with="hematite_nbt::i64_array")] +/// #[serde(serialize_with="nbt::i64_array")] /// long_data: Vec, /// } /// +/// // Serialize to NBT! /// to_writer( -/// &mut writer, +/// &mut serialized, /// &Enderman { -/// long_data: vec![0xc848ccd2157df10e, 0xf4c5efff28280e9a], +/// long_data: vec![0x1848ccd2157df10e, 0x64c5efff28280e9a], /// }, /// None -/// )?; +/// ).unwrap(); +/// +/// print!("Serialized: {:?}", serialized); /// ``` pub fn i64_array<'a, T, S>(array: &'a T, serializer: S) -> std::result::Result where