fengsp / pencil

A web application microframework for Rust
https://fengsp.github.io/pencil/
Other
869 stars 39 forks source link

Provide a `remove()` in `MultiDict` #32

Open golddranks opened 8 years ago

golddranks commented 8 years ago

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 commented 8 years ago

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("");