rhodonite
    Preparing search index...

    Class Some<T>

    A class representing an Option that contains a value. This is the "Some" variant of the Option type, indicating that a value exists.

    Type Parameters

    • T

      The type of the contained value

    Implements

    • IOption<T>
    Index

    Constructors

    • Creates a new Some instance with the provided value.

      Type Parameters

      • T

        The type of the contained value

      Parameters

      • value: NonNullable<T>

        The non-null value to wrap

      Returns Some<T>

    Methods

    • Applies a function to the contained value and returns the result. This method is essentially the same as Some::and_then() in Rust language.

      Type Parameters

      • U

        The type of the value returned by the function

      Parameters

      • f: (value: NonNullable<T>) => Option<NonNullable<U>>

        Function to apply to the contained value

      Returns Option<NonNullable<U>>

      The result of applying f to the contained value

    • Type guard that always returns false for Some instances.

      Returns this is None

      Always false, indicating this Option contains a value

    • Gets the contained value directly. This is a convenience method for accessing the wrapped value.

      Returns NonNullable<T>

      The contained value

    • Type guard that always returns true for Some instances.

      Returns this is Some<NonNullable<T>>

      Always true, indicating this Option contains a value

    • Executes the Some handler function with the contained value.

      Type Parameters

      • U

        The return type of the match functions

      Parameters

      • obj: {
            None: () => U | NonNullable<U>;
            Some: (value: NonNullable<T>) => U | NonNullable<U>;
        }

        Object containing Some and None handler functions

      Returns U | NonNullable<U>

      The result of executing obj.Some with the contained value

    • Returns this Some instance, ignoring the provided function. Since this Option already contains a value, the alternative is not needed.

      Type Parameters

      • U

        The type of the alternative Option (unused)

      Parameters

      Returns Option<NonNullable<U>>

      This Some instance cast to the appropriate type

    • Returns the contained value. This method never throws since Some always contains a value.

      Returns NonNullable<T>

      The contained value

    • Returns the contained value, ignoring the provided default. Since this Option contains a value, the alternative is not needed.

      Parameters

      • _altValue: NonNullable<T>

      Returns NonNullable<T>

      The contained value

    • Returns the contained value, ignoring the provided function. Since this Option contains a value, the alternative is not needed.

      Parameters

      • _f: () => NonNullable<T>

      Returns NonNullable<T>

      The contained value

    • Returns the contained value. This method never returns undefined since Some always contains a value.

      Returns NonNullable<T> | undefined

      The contained value