@@ -29,7 +29,7 @@ might work, but they are subject to the minimum that Rocket sets.
2929Add the following to Cargo.toml:
3030
3131```toml
32- rocket_cors = "0.5.0-beta-2 "
32+ rocket_cors = "0.5.1 "
3333```
3434
3535To use the latest `master` branch, for example:
@@ -45,7 +45,7 @@ the [`CorsOptions`] struct that is described below. If you would like to disable
4545change your `Cargo.toml` to:
4646
4747```toml
48- rocket_cors = { version = "0.5.0 ", default-features = false }
48+ rocket_cors = { version = "0.5.1 ", default-features = false }
4949```
5050
5151## Usage
@@ -258,7 +258,6 @@ See the [example](https://github.com/lawliet89/rocket_cors/blob/master/examples/
258258 while_true
259259) ]
260260#![ allow(
261- legacy_directory_ownership,
262261 missing_copy_implementations,
263262 missing_debug_implementations,
264263 unknown_lints,
@@ -812,12 +811,12 @@ impl ParsedAllowedOrigins {
812811 exact. into_iter ( ) . partition ( |( _, url) | url. is_tuple ( ) ) ;
813812
814813 if !opaque. is_empty ( ) {
815- Err ( Error :: OpaqueAllowedOrigin (
814+ return Err ( Error :: OpaqueAllowedOrigin (
816815 opaque
817816 . into_iter ( )
818817 . map ( |( original, _) | original. to_string ( ) )
819818 . collect ( ) ,
820- ) ) ?
819+ ) ) ;
821820 }
822821
823822 let exact = tuple. into_iter ( ) . map ( |( _, url) | url) . collect ( ) ;
@@ -907,7 +906,7 @@ pub type AllowedHeaders = AllOrSome<HashSet<HeaderFieldName>>;
907906impl AllowedHeaders {
908907 /// Allow some headers
909908 pub fn some ( headers : & [ & str ] ) -> Self {
910- AllOrSome :: Some ( headers. iter ( ) . map ( |s| s . to_string ( ) . into ( ) ) . collect ( ) )
909+ AllOrSome :: Some ( headers. iter ( ) . map ( |s| ( * s ) . to_string ( ) . into ( ) ) . collect ( ) )
911910 }
912911
913912 /// Allows all headers
@@ -1143,7 +1142,7 @@ impl CorsOptions {
11431142 /// Validates if any of the settings are disallowed, incorrect, or illegal
11441143 pub fn validate ( & self ) -> Result < ( ) , Error > {
11451144 if self . allowed_origins . is_all ( ) && self . send_wildcard && self . allow_credentials {
1146- Err ( Error :: CredentialsWithWildcardOrigin ) ? ;
1145+ return Err ( Error :: CredentialsWithWildcardOrigin ) ;
11471146 }
11481147
11491148 Ok ( ( ) )
@@ -1296,7 +1295,7 @@ impl Response {
12961295 /// Consumes the CORS, set expose_headers to
12971296 /// passed headers and returns changed CORS
12981297 fn exposed_headers ( mut self , headers : & [ & str ] ) -> Self {
1299- self . expose_headers = headers. iter ( ) . map ( |s| s . to_string ( ) . into ( ) ) . collect ( ) ;
1298+ self . expose_headers = headers. iter ( ) . map ( |s| ( * s ) . to_string ( ) . into ( ) ) . collect ( ) ;
13001299 self
13011300 }
13021301
@@ -1317,7 +1316,7 @@ impl Response {
13171316 /// Consumes the CORS, set allow_headers to
13181317 /// passed headers and returns changed CORS
13191318 fn headers ( mut self , headers : & [ & str ] ) -> Self {
1320- self . allow_headers = headers. iter ( ) . map ( |s| s . to_string ( ) . into ( ) ) . collect ( ) ;
1319+ self . allow_headers = headers. iter ( ) . map ( |s| ( * s ) . to_string ( ) . into ( ) ) . collect ( ) ;
13211320 self
13221321 }
13231322
@@ -1680,7 +1679,7 @@ fn validate_allowed_method(
16801679) -> Result < ( ) , Error > {
16811680 let & AccessControlRequestMethod ( ref request_method) = method;
16821681 if !allowed_methods. iter ( ) . any ( |m| m == request_method) {
1683- Err ( Error :: MethodNotAllowed ( method. 0 . to_string ( ) ) ) ?
1682+ return Err ( Error :: MethodNotAllowed ( method. 0 . to_string ( ) ) ) ;
16841683 }
16851684
16861685 // TODO: Subset to route? Or just the method requested for?
@@ -1698,7 +1697,7 @@ fn validate_allowed_headers(
16981697 AllOrSome :: All => Ok ( ( ) ) ,
16991698 AllOrSome :: Some ( ref allowed_headers) => {
17001699 if !headers. is_empty ( ) && !headers. is_subset ( allowed_headers) {
1701- Err ( Error :: HeadersNotAllowed ) ?
1700+ return Err ( Error :: HeadersNotAllowed ) ;
17021701 }
17031702 Ok ( ( ) )
17041703 }
@@ -1991,7 +1990,7 @@ mod tests {
19911990 allow_credentials : true ,
19921991 expose_headers : [ "Content-Type" , "X-Custom" ]
19931992 . iter ( )
1994- . map ( |s| s . to_string ( ) )
1993+ . map ( |s| ( * s ) . to_string ( ) )
19951994 . collect ( ) ,
19961995 ..Default :: default ( )
19971996 }
0 commit comments