File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 10
10
//!
11
11
//! assert_eq!(url.mime_type().type_, "text");
12
12
//! assert_eq!(url.mime_type().subtype, "plain");
13
- //! assert_eq!(url.mime_type().parameters, [ ("charset".into( ), "US-ASCII".into())] );
13
+ //! assert_eq!(url.mime_type().get_parameter ("charset"), Some( "US-ASCII") );
14
14
//! assert_eq!(body, b"Hello World!");
15
15
//! assert!(fragment.is_none());
16
16
//! ```
Original file line number Diff line number Diff line change @@ -10,6 +10,16 @@ pub struct Mime {
10
10
pub parameters : Vec < ( String , String ) >
11
11
}
12
12
13
+ impl Mime {
14
+ pub fn get_parameter < P > ( & self , name : & P ) -> Option < & str >
15
+ where P : ?Sized + PartialEq < str >
16
+ {
17
+ self . parameters . iter ( )
18
+ . find ( |& & ( ref n, _) | name == & * * n)
19
+ . map ( |& ( _, ref v) | & * * v)
20
+ }
21
+ }
22
+
13
23
#[ derive( Debug ) ]
14
24
pub struct MimeParsingError ( ( ) ) ;
15
25
You can’t perform that action at this time.
0 commit comments