Skip to main content

null

Function null 

Source
pub fn null() -> Box<Layout>
Expand description

Creates an empty layout node.

The null layout produces no output and serves as a neutral element in compositions. It’s useful as a placeholder or when building layouts conditionally.

§Returns

A boxed Layout::Null that produces no visible output.

§Examples

use typeset::*;

// Use null as a placeholder in conditional layouts
let should_include_prefix = false;
let layout = if should_include_prefix {
    text("prefix: ".to_string())
} else {
    null()
};

// Null is neutral in compositions
let result = comp(null(), text("content".to_string()), true, false);
assert_eq!(format_layout(result, 2, 80), "content");

§See Also

  • text - For creating text content
  • [comp] - For composing layouts together