reem/rust-plugin — pull request #1 by michaelsproul (2014-08-18 07:42:33+00:00)
Title: Add infallible plugins and customisable return types.

I've been playing with `rust-plugin`'s code in an attempt to add infallible plugins. I ended up just adding infallible variants of the regular `get` methods, as anything else requires the addition of higher kinded types or other stuff to Rust itself.

`cargo doc` is possibly the best way to get a feel for the changes as there are a billion lifetime parameters in the code itself. I hit an ICE when trying to infer lifetimes across closures passed as arguments to functions.

I think infallible plugins might be useful for Iron, as there are some cases where failure is impossible: `request.get_certain::()`. Initially I thought they would also be useful for things like URL encoding, to avoid a double option type like `Option)>` but I now realise that the parsing should be done in the creation of the `UrlEncodedData`.

Perhaps infallible plugins aren't that useful for Iron (most data parsing can fail in some way?).

The other thing I've added is customisable return types, so that you can return any type from a plugin's get method.

```rust
// With custom return types
request.get::() // -> Option>

// Without (more unpacking required)
request.get::() // -> Option>)>
```

Thoughts?