Skip to content

Commit

Permalink
Fix documentation examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Schuwi committed Jun 17, 2020
1 parent e111611 commit 4d032bd
Showing 1 changed file with 37 additions and 13 deletions.
50 changes: 37 additions & 13 deletions src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<i8>,
/// }
///
/// // 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<S::Ok, S::Error>
where
Expand All @@ -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<i32>,
/// }
///
/// // 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<S::Ok, S::Error>
where
Expand All @@ -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<i64>,
/// }
///
/// // 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<S::Ok, S::Error>
where
Expand Down

0 comments on commit 4d032bd

Please sign in to comment.