arcis 0.12.0

A standard library of types and functions for writing MPC circuits with the Arcis framework.
Documentation
//! Methods on [`Option`] accepted by the arcis interpreter.
//!
//! [`Option`] here is a documentation-only redefinition of
//! [`std::option::Option`] — same shape, but with bodies that panic, since
//! the arcis interpreter intercepts the real method before they run.

const STUB_MSG: &str = "arcis::std::option is documentation-only; \
    inside `#[encrypted]` code the interpreter intercepts the real method before this stub runs.";

/// Documentation of methods on [`Option<T>`](std::option::Option) accepted by
/// the arcis interpreter. Mirrors [`std::option::Option`]'s shape.
pub enum Option<T> {
    /// No value.
    None,
    /// Some value of type `T`.
    Some(T),
}

impl<T> Option<T> {
    /// Returns `true` if the option is a `Some`.
    pub fn is_some(&self) -> ::core::primitive::bool {
        unimplemented!("{STUB_MSG}")
    }

    /// Returns `true` if the option is a `None`.
    pub fn is_none(&self) -> ::core::primitive::bool {
        unimplemented!("{STUB_MSG}")
    }

    /// Returns `true` if the option is a `Some` matching `f`.
    pub fn is_some_and(
        self,
        f: impl FnOnce(T) -> ::core::primitive::bool,
    ) -> ::core::primitive::bool {
        unimplemented!("{STUB_MSG}")
    }

    /// Returns `true` if the option is `None` or if the contained value matches `f`.
    pub fn is_none_or(
        self,
        f: impl FnOnce(T) -> ::core::primitive::bool,
    ) -> ::core::primitive::bool {
        unimplemented!("{STUB_MSG}")
    }

    /// Returns the contained `Some` value.
    pub fn unwrap(self) -> T {
        unimplemented!("{STUB_MSG}")
    }

    /// Returns the contained `Some` value or the provided default.
    pub fn unwrap_or(self, default: T) -> T {
        unimplemented!("{STUB_MSG}")
    }

    /// Returns the contained `Some` value or computes it from `f`.
    pub fn unwrap_or_else(self, f: impl FnOnce() -> T) -> T {
        unimplemented!("{STUB_MSG}")
    }

    /// Maps `Option<T>` to `Option<U>` by applying `f`.
    pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Option<U> {
        unimplemented!("{STUB_MSG}")
    }

    /// Maps to `U`, with a default for `None`.
    pub fn map_or<U>(self, default: U, f: impl FnOnce(T) -> U) -> U {
        unimplemented!("{STUB_MSG}")
    }

    /// Maps to `U`, computing the default for `None`.
    pub fn map_or_else<U>(self, default_f: impl FnOnce() -> U, f: impl FnOnce(T) -> U) -> U {
        unimplemented!("{STUB_MSG}")
    }

    /// Calls `f` with the contained value (if any) and returns the option.
    pub fn inspect(self, f: impl FnOnce(&T)) -> Option<T> {
        unimplemented!("{STUB_MSG}")
    }

    /// Returns the option if its `Some` value matches the predicate.
    pub fn filter(self, predicate: impl FnOnce(&T) -> ::core::primitive::bool) -> Option<T> {
        unimplemented!("{STUB_MSG}")
    }

    /// Returns `other` if `self` is `Some`, otherwise `None`.
    pub fn and<U>(self, other: Option<U>) -> Option<U> {
        unimplemented!("{STUB_MSG}")
    }

    /// Returns `f` applied to the contained value (if any), otherwise `None`.
    pub fn and_then<U>(self, f: impl FnOnce(T) -> Option<U>) -> Option<U> {
        unimplemented!("{STUB_MSG}")
    }

    /// Returns the option if it's `Some`, otherwise returns `other`.
    pub fn or(self, other: Option<T>) -> Option<T> {
        unimplemented!("{STUB_MSG}")
    }

    /// Returns the option if it's `Some`, otherwise calls `f`.
    pub fn or_else(self, f: impl FnOnce() -> Option<T>) -> Option<T> {
        unimplemented!("{STUB_MSG}")
    }

    /// Returns `Some` if exactly one of `self`, `other` is `Some`.
    pub fn xor(self, other: Option<T>) -> Option<T> {
        unimplemented!("{STUB_MSG}")
    }

    /// Zips with another option, yielding `Some((t, u))` only if both are `Some`.
    pub fn zip<U>(self, other: Option<U>) -> Option<(T, U)> {
        unimplemented!("{STUB_MSG}")
    }

    /// Takes the value out, leaving `None` in its place.
    pub fn take(&mut self) -> Option<T> {
        unimplemented!("{STUB_MSG}")
    }

    /// Takes the value out if the predicate holds.
    pub fn take_if(
        &mut self,
        predicate: impl FnOnce(&mut T) -> ::core::primitive::bool,
    ) -> Option<T> {
        unimplemented!("{STUB_MSG}")
    }

    /// Replaces the value, returning the old.
    pub fn replace(&mut self, value: T) -> Option<T> {
        unimplemented!("{STUB_MSG}")
    }

    /// Inserts the value, returning a mutable reference.
    pub fn insert(&mut self, value: T) -> &mut T {
        unimplemented!("{STUB_MSG}")
    }

    /// Inserts `value` if the option is `None`, returns a mutable reference.
    pub fn get_or_insert(&mut self, value: T) -> &mut T {
        unimplemented!("{STUB_MSG}")
    }

    /// Inserts the result of `f` if the option is `None`.
    pub fn get_or_insert_with(&mut self, f: impl FnOnce() -> T) -> &mut T {
        unimplemented!("{STUB_MSG}")
    }
}

impl<T, U> Option<(T, U)> {
    /// Unzips an `Option<(T, U)>` into `(Option<T>, Option<U>)`.
    pub fn unzip(self) -> (Option<T>, Option<U>) {
        unimplemented!("{STUB_MSG}")
    }
}

impl<T> Option<Option<T>> {
    /// Converts `Option<Option<T>>` to `Option<T>`.
    pub fn flatten(self) -> Option<T> {
        unimplemented!("{STUB_MSG}")
    }
}

impl<T: Copy> Option<&T> {
    /// Maps `Option<&T>` to `Option<T>` by copying.
    pub fn copied(self) -> Option<T> {
        unimplemented!("{STUB_MSG}")
    }
}

impl<T: Clone> Option<&T> {
    /// Maps `Option<&T>` to `Option<T>` by cloning.
    pub fn cloned(self) -> Option<T> {
        unimplemented!("{STUB_MSG}")
    }
}