Skip to main content

some

@ts-rust/std


@ts-rust/std / Option / some

Function: some()

function some<T>(value): Option<T>;

Defined in: packages/std/src/option/option.ts:43

Creates a Some variant of an Option containing the given value.

Wraps the provided value in a Some, indicating the presence of a value.

Type Parameters

Type ParameterDescription

T

The type of the value.

Parameters

ParameterTypeDescription

value

T

The value to wrap in Some.

Returns

Option<T>

An Option containing the value as Some.

Example

const x = some(42);

expect(x.isSome()).toBe(true);
expect(x.expect("Not 42")).toBe(42);