pub enum Fields<T> {
Zero,
Single(T),
At(Vec<T>),
Star(Vec<T>),
Split(Vec<T>),
}Expand description
Represents the types of fields that may result from evaluating a word.
It is important to maintain such distinctions because evaluating parameters
such as $@ and $* have different behaviors in different contexts.
Variants§
Zero
No fields, distinct from present-but-null fields.
Single(T)
A single field.
At(Vec<T>)
Any number of fields resulting from evaluating the $@ special parameter.
Star(Vec<T>)
Any number of fields resulting from evaluating the $* special parameter.
Split(Vec<T>)
A non-zero number of fields resulting from splitting, and which do not have any special meaning.
Implementations§
Source§impl<T: StringWrapper> Fields<T>
impl<T: StringWrapper> Fields<T>
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Indicates if a set of fields is considered null.
A set of fields is null if every single string it holds is the empty string.
Sourcepub fn join(self) -> T
pub fn join(self) -> T
Joins all fields using a space.
Note: Zero is treated as a empty-but-present field for simplicity.
Sourcepub fn join_with_ifs<E>(self, env: &E) -> T
pub fn join_with_ifs<E>(self, env: &E) -> T
Joins any field unconditionally with the first character of $IFS.
If $IFS is unset, fields are joined with a space, or concatenated
if $IFS is empty.
Note: Zero is treated as a empty-but-present field for simplicity.