@@ -270,7 +270,7 @@ will be routed as follows:
270270 You'll also find a route's rank logged in brackets during application launch:
271271 ` GET /user/<id> [3] (user_str) ` .
272272
273- Forwards can be _ caught_ by using a ` Result ` or ` Option ` type. For example, if
273+ Forwards can be _ caught_ by using a ` Option ` type. For example, if
274274the type of ` id ` in the ` user ` function was ` Result<usize, &str> ` , then ` user `
275275would never forward. An ` Ok ` variant would indicate that ` <id> ` was a valid
276276` usize ` , while an ` Err ` would indicate that ` <id> ` was not a ` usize ` . The
@@ -279,7 +279,7 @@ would never forward. An `Ok` variant would indicate that `<id>` was a valid
279279! tip: It's not just forwards that can be caught!
280280
281281 In general, when any guard fails for any reason, including parameter guards,
282- you can use an ` Option ` or ` Result ` type in its place to catch the error.
282+ you can use a ` Result ` type in its place to catch the error.
283283
284284By the way, if you were to omit the ` rank ` parameter in the ` user_str ` or
285285` user_int ` routes, Rocket would emit an error and abort launch, indicating that
@@ -511,8 +511,7 @@ it always succeeds. The user is redirected to a log in page.
511511### Fallible Guards
512512
513513A failing or forwarding guard can be "caught" in handler, preventing it from
514- failing or forwarding, via the ` Option<T> ` and ` Result<T, E> ` guards. When a
515- guard ` T ` fails or forwards, ` Option<T> ` will be ` None ` . If a guard ` T ` fails
514+ failing or forwarding, via ` Result<T, E> ` guards. If a guard ` T ` fails
516515with error ` E ` , ` Result<T, E> ` will be ` Err(E) ` .
517516
518517As an example, for the ` User ` guard above, instead of allowing the guard to
@@ -538,7 +537,7 @@ fn admin_panel_user(user: Option<User>) -> Result<&'static str, Redirect> {
538537}
539538```
540539
541- If the ` User ` guard forwards or fails , the ` Option ` will be ` None ` . If it
540+ If the ` User ` guard forwards, the ` Option ` will be ` None ` . If it
542541succeeds, it will be ` Some(User) ` .
543542
544543For guards that may fail (and not just forward), the ` Result<T, E> ` guard allows
@@ -898,14 +897,14 @@ If a `POST /todo` request arrives, the form data will automatically be parsed
898897into the ` Task ` structure. If the data that arrives isn't of the correct
899898Content-Type, the request is forwarded. If the data doesn't parse or is simply
900899invalid, a customizable error is returned. As before, a forward or error can
901- be caught by using the ` Option ` and ` Result ` types:
900+ be caught by using the ` Result ` types:
902901
903902``` rust
904- # use rocket :: {post, form :: Form };
903+ # use rocket :: {post, form :: { Form , Errors } };
905904# type Task <'r > = & 'r str ;
906905
907906#[post(" /todo" , data = " <task>" )]
908- fn new (task : Option <Form <Task <'_ >>>) { /* .. */ }
907+ fn new (task : Result <Form <Task <'_ >>, Errors <' _ >>) { /* .. */ }
909908```
910909
911910### Multipart
0 commit comments