Struct codize::List

source ·
pub struct List {
    pub separator: String,
    pub trailing: Trailing,
    /* private fields */
}
Expand description

A list of code segments separated by a separator

Fields§

§separator: String

The separator between the items

§trailing: Trailing

The trailing mode

Implementations§

source§

impl List

source

pub fn empty<TSep: ToString>(sep: TSep) -> Self

Create a new empty code list

source

pub fn new<TSep, TBody>(sep: TSep, body: TBody) -> Self
where TSep: ToString, TBody: IntoIterator, TBody::Item: Into<Code>,

Create a new code list

source

pub fn no_trail(self) -> Self

Create a new code list with no trailing separator

source

pub fn always_trail(self) -> Self

Create a new code list with trailing separator even if the list is in one line

source

pub fn inline_when(self, condition: fn(_: &List) -> bool) -> Self

Set a condition for displaying the block as one line

source

pub fn inlined(self) -> Self

Set the inline condition to be always true

source

pub fn never_inlined(self) -> Self

Set the inline condition to be always false

source

pub fn body(&self) -> &[Code]

Get the body of the block

source

pub fn is_empty(&self) -> bool

Get if the list will generate any code or not (empty = no code)

source

pub fn should_inline(&self) -> bool

Should the list be displayed in one line

source

pub fn should_inline_intrinsic(&self) -> bool

Should intrinsicly inline the list

This is used for lists that only contain one item

Trait Implementations§

source§

impl Debug for List

source§

fn fmt(&self, __f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for List

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FormatCode for List

source§

fn size_hint(&self) -> usize

Upperbound for the line count of the code for pre-allocating. Return 0 to skip
source§

fn format_into_vec_with( &self, format: &Format, out: &mut Vec<String>, connect: bool, indent: &str )

Emit self with the format in the given output context
source§

fn format(&self) -> String

Emit self with the default format as a string
source§

fn format_with(&self, format: &Format) -> String

Emit self with the format as a string
source§

fn format_vec_with(&self, format: &Format) -> Vec<String>

Emit self with the format as a vector of lines
source§

impl From<List> for Code

source§

fn from(x: List) -> Self

Converts to this type from the input type.
source§

impl PartialEq for List

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl Freeze for List

§

impl RefUnwindSafe for List

§

impl Send for List

§

impl Sync for List

§

impl Unpin for List

§

impl UnwindSafe for List

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.