Skip to content

Add a function similar to Option::map #70

Description

@funnyboy-roks

It would be convenient to have a utility function for mapping the value inside of a secret, basically following this signature:

fn map<F, U>(self, mapper: F) -> Secret<U>
    where F: FnOnce(T) -> U

My specific use case is that I have a Secret<&str> and I need a Secret<Cow<'a, str>> and it's messy to have to do something like

Secret::new(Cow::Borrowed(secret.expose_secret()))

where something like this could be better:

secret.map(Cow::Borrowed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions