Skip to main content

NonEmptyOrExt

Trait NonEmptyOrExt 

Source
pub trait NonEmptyOrExt: Sized {
    // Required method
    fn nonempty_or_else(self, default: impl FnOnce() -> Self) -> Self;

    // Provided method
    fn nonempty_or(self, value: Self) -> Self { ... }
}
Expand description

Extension trait for owned strings providing an empty-string fallback.

Required Methods§

Source

fn nonempty_or_else(self, default: impl FnOnce() -> Self) -> Self

Same as Self::nonempty_or but takes a factory function.

Provided Methods§

Source

fn nonempty_or(self, value: Self) -> Self

Return the string if it is non-empty, otherwise value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl NonEmptyOrExt for &str

Source§

fn nonempty_or_else(self, default: impl FnOnce() -> Self) -> Self

Source§

impl NonEmptyOrExt for String

Source§

fn nonempty_or_else(self, default: impl FnOnce() -> Self) -> Self

Source§

impl<T> NonEmptyOrExt for &[T]

Source§

fn nonempty_or_else(self, default: impl FnOnce() -> Self) -> Self

Source§

impl<T> NonEmptyOrExt for Vec<T>

Source§

fn nonempty_or_else(self, default: impl FnOnce() -> Self) -> Self

Implementors§