#[non_exhaustive]pub enum Space {
None,
Single,
SoftLine,
Line,
Hard,
}Expand description
What goes between two neighbouring pieces of output.
The five values form a small lattice. When several rules speak about the
same gap, the formatter takes the most generous answer: a gap gets a space if
any rule asks for one, may break if any rule allows it, and always breaks if
any rule demands it. So SoftLine combined with
Single is Line, and anything combined
with Hard is Hard.
| Value | When the enclosing group fits | When it breaks |
|---|---|---|
None | nothing | nothing |
Single | one space | one space |
SoftLine | nothing | a line break |
Line | one space | a line break |
Hard | a line break | a line break |
A gap that resolves to Hard keeps up to the configured number of blank
lines the source had there (Rules::max_blank_lines,
NodeRule::blank_lines).
§Examples
use fmt_lang::{Rules, Space, TokenRule};
// No space before a comma, one after it.
let rules = Rules::new().token(TokenRule::new(",").before(Space::None).after(Space::Single));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
None
Nothing: the neighbours touch.
Single
Exactly one space.
SoftLine
Nothing, or a line break when the enclosing group does not fit.
Line
One space, or a line break when the enclosing group does not fit.
Hard
Always a line break.
Trait Implementations§
impl Copy for Space
impl Eq for Space
impl StructuralPartialEq for Space
Auto Trait Implementations§
impl Freeze for Space
impl RefUnwindSafe for Space
impl Send for Space
impl Sync for Space
impl Unpin for Space
impl UnsafeUnpin for Space
impl UnwindSafe for Space
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