pub fn space() -> Box<Layout>
Expand description
Creates a single space character layout.
This is a convenience function equivalent to text_str(" ")
. It’s commonly
used in compositions and as a separator in joining operations.
§Returns
A boxed [Layout::Text
] containing a single space.
§Examples
use typeset::*;
// Use space in compositions
let spaced = comp(
text_str("Hello"),
comp(space(), text_str("world"), false, false),
false, false
);
assert_eq!(format_layout(spaced, 2, 80), "Hello world");
use typeset::*;
// Equivalent to padded composition
let explicit = comp(text_str("A"), comp(space(), text_str("B"), false, false), false, false);
let padded = comp(text_str("A"), text_str("B"), true, false);
assert_eq!(
format_layout(explicit, 2, 80),
format_layout(padded, 2, 80)
);
§See Also
- [
join_with_spaces
] - Joins layouts with spaces - [
comp
] - Thepad=true
parameter provides automatic spacing