pub fn fix_unpad(left: Box<Layout>, right: Box<Layout>) -> Box<Layout>Expand description
Creates a fixed, unpadded composition between two layouts.
This convenience function creates a composition with padding disabled but
fixing enabled. The layouts are always placed directly adjacent on the same
line with no space between them, regardless of width constraints. This is
equivalent to comp(left, right, false, true) and is useful for compound
tokens or syntactic elements that must never be separated.
§Parameters
left- The left layout in the compositionright- The right layout in the composition
§Returns
A fixed, unpadded composition that never breaks or adds spaces.
§Examples
use typeset::*;
// Compound operators that must stay together
let arrow = fix_unpad(
text_str("-"),
text_str(">")
);
assert_eq!(format_layout(arrow, 2, 80), "->");use typeset::*;
// String prefixes or suffixes
let raw_string = fix_unpad(
text_str("r"),
text_str("\"content\"")
);
assert_eq!(format_layout(raw_string, 2, 80), "r\"content\"");use typeset::*;
// Multi-character operators
let equality = fix_unpad(
text_str("="),
text_str("=")
);
// Use in larger expressions
let comparison = pad(
text_str("a"),
pad(equality, text_str("b"))
);
assert_eq!(format_layout(comparison, 2, 80), "a == b");§Behavior
- Padding:
false- No space added between layouts - Fixing:
true- Never breaks, regardless of width constraints - Creates indivisible compound tokens
- Use with caution - can cause lines to exceed width limits
- The layouts are always directly adjacent
§Use Cases
- Multi-character operators (“==”, “!=”, “->”, “<=”)
- Prefixed literals (“0x”, “0b”, raw strings)
- Compound symbols that lose meaning when separated
- Token sequences that form single logical units