pub struct Spacing {
pub lines_between_scalar_fields: usize,
pub lines_between_scalar_field_comments: usize,
pub lines_between_tables: usize,
}
Expand description
Determines the spacing between fields.
Fields§
§lines_between_scalar_fields: usize
How many lines to use to split scalar fields:
use doku::Document;
#[derive(Document)]
struct Person {
/// Person's name
name: String,
surname: String,
/// Person's address
address: String,
}
let fmt = doku::toml::Formatting {
spacing: doku::toml::Spacing {
lines_between_scalar_fields: 1,
..Default::default()
},
..Default::default()
};
let doc = doku::to_toml_fmt::<Person>(&fmt);
doku::assert_doc!(r#"
# Person's name
name = "string"
surname = "string"
# Person's address
address = "string"
"#, doc);
lines_between_scalar_field_comments: usize
How many lines to use before a scalar field’s comment:
use doku::Document;
#[derive(Document)]
struct Person {
/// Person's name
name: String,
surname: String,
/// Person's address
address: String,
}
let fmt = doku::toml::Formatting {
spacing: doku::toml::Spacing {
lines_between_scalar_field_comments: 1,
..Default::default()
},
..Default::default()
};
let doc = doku::to_toml_fmt::<Person>(&fmt);
doku::assert_doc!(r#"
# Person's name
name = "string"
surname = "string"
# Person's address
address = "string"
"#, doc);
lines_between_tables: usize
How many lines to use to split tables:
use doku::Document;
#[derive(Document)]
struct Person {
name: String,
address: Address,
}
#[derive(Document)]
struct Address {
street: String,
number: u32
}
let fmt = doku::toml::Formatting {
spacing: doku::toml::Spacing {
lines_between_tables: 2,
..Default::default()
},
..Default::default()
};
let doc = doku::to_toml_fmt::<Person>(&fmt);
doku::assert_doc!(r#"
name = "string"
[address]
street = "string"
number = 123
"#, doc);
Trait Implementations§
source§impl<'de> Deserialize<'de> for Spacing
impl<'de> Deserialize<'de> for Spacing
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for Spacing
impl Send for Spacing
impl Sync for Spacing
impl Unpin for Spacing
impl UnwindSafe for Spacing
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more