Skip to content

Tracking Issue for constifying Result methods that drop values #92384

Closed
@clarfonthey

Description

@clarfonthey

Feature gate: #![feature(const_result_drop)]

Public API

This is a tracking issue for the const_result_drop feature, which includes constness for the following methods:

impl<T, E> Result<T, E> {
    // will drop error
    pub const fn ok(self) -> Option<T>
    where
        E: ~const Drop;

    // will drop ok
    pub const fn err(self) -> Option<E>
    where
        T: ~const Drop;

    // will drop error or the argument
    pub const fn and<U>(self, res: Result<U, E>) -> Result<U, E>
    where
        T: ~const Drop,
        U: ~const Drop,
        E: ~const Drop;
    
    // will drop ok or the argument
    pub const fn or<F>(self, res: Result<T, F>) -> Result<T, F>
    where
        T: ~const Drop,
        E: ~const Drop,
        F: ~const Drop;

    // will drop error or the argument
    pub const fn unwrap_or(self, default: T) -> T
    where
        T: ~const Drop,
        E: ~const Drop;
}

Note that these depend on the semantics for ~const Drop, which is (probably) tracked in #67792.

Steps / History

Unresolved Questions

  • None yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-const_trait_impl`#![feature(const_trait_impl)]`T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions