pencil icon indicating copy to clipboard operation
pencil copied to clipboard

Provide a `remove()` in `MultiDict`

Open golddranks opened this issue 9 years ago • 1 comments

Patterns like this

 let email = login_form.remove("email").unwrap_or_else(|| "".into());

can't be used without remove(), i.e. a getter that provides the value as a value, not as a reference.

I think that another way to improve this would be that the return type of request.form() would have &strs instead of Strings, possibly even in a zero-copy way. The user could then clone() if they wanted or needed to.

golddranks avatar Sep 15 '16 19:09 golddranks

Btw. a surprisingly tidy workaround for this. But getting rid of the map would be ideal.

    let email = login_form.get("email").map(String::as_ref).unwrap_or("");

golddranks avatar Sep 15 '16 20:09 golddranks