Skip to content

Tracking Issue for smart pointer (try_)map #144419

@Qelxiros

Description

@Qelxiros

Feature gate: #![feature(smart_pointer_try_map)]

This is a tracking issue for map and try_map functions for various smart pointer types, as per rust-lang/libs-team#364

Public API

// Taking T by value
impl Box<T> {
    fn map<U>(this: Self, f: impl FnOnce(T) -> U) -> Box<U>;
    fn try_map<R>(this: Self, f: impl FnOnce(T) -> R) -> ChangeOutputType<R, Box<R::Output>>
    where
        R: Try,
        R::Residual: Residual<Box<R::Output, A>>;
}
impl UniqueRc<T> {
    fn map<U>(this: Self, f: impl FnOnce(T) -> U) -> UniqueRc<U>;
    fn try_map<R>(this: Self, f: impl FnOnce(T) -> R) -> ChangeOutputType<R, UniqueRc<R::Output>>
    where
        R: Try,
        R::Residual: Residual<UniqueRc<R::Output, A>>;
}
impl UniqueArc<T> {
    fn map<U>(this: Self, f: impl FnOnce(T) -> U) -> UniqueArc<U>;
    fn try_map<R>(this: Self, f: impl FnOnce(T) -> R) -> ChangeOutputType<R, UniqueArc<R::Output>>
    where
        R: Try,
        R::Residual: Residual<UniqueArc<R::Output, A>>;
}

// Taking T by reference
impl Rc<T> {
    fn map<U>(this: Self, f: impl FnOnce(&T) -> U) -> Rc<U>;
    fn try_map<R>(this: Self, f: impl FnOnce(&T) -> R) -> ChangeOutputType<R, Rc<R::Output>>
    where
        R: Try,
        R::Residual: Residual<Rc<R::Output, A>>;
}
impl Arc<T> {
    fn map<U>(this: Self, f: impl FnOnce(&T) -> U) -> Arc<<U>;
    fn try_map<R>(this: Self, f: impl FnOnce(&T) -> R) -> ChangeOutputType<R, Arc<<R::Output>>
    where
        R: Try,
        R::Residual: Residual<Arc<R::Output, A>>;
}

Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

Unresolved Questions

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.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