pub fn text(data: String) -> Box<Layout>Expand description
Creates a text layout containing the given string.
Text layouts are the fundamental building blocks that produce visible output. The text content is treated as a single unit that cannot be broken across lines.
§Parameters
data- The string content to include in the layout
§Returns
A boxed Layout::Text containing the provided string.
§Examples
use typeset::*;
// Create simple text
let hello = text("Hello, world!".to_string());
assert_eq!(format_layout(hello, 2, 80), "Hello, world!");
// Text preserves whitespace and special characters
let code = text(" fn main() {".to_string());
assert_eq!(format_layout(code, 2, 80), " fn main() {");§See Also
text_str- Convenience function that takes&str- [
comp] - For combining text with other layouts - [
fix] - For ensuring text never breaks