Skip to content

Please, impl Into<&'t str> for Match<'t> #357

@jan-hudec

Description

@jan-hudec

The Match::as_str takes &self, so it can't be directly mapped onto the Option<Match<'t>> returned by get and name. A version consuming the Match would be more convenient for the purpose. And standard conversion From/Into seem to fit here.

Basically, code that used captures.name("foo") now needs to use captures.name("foo").as_ref().map(Match::as_str) or captures.name("foo").map(|m| m.as_str()). With Into, it should be able to use captures.name("foo").map(From::from).

Some code can be changed to use Match directly, but anything that wants to continue with something like .unwrap_or("") needs to convert to string.

Also note that Index does not seem to fit the bill, because code that needs Option can't use that.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions