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 1010//!
1111//! assert_eq!(url.mime_type().type_, "text");
1212//! 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") );
1414//! assert_eq!(body, b"Hello World!");
1515//! assert!(fragment.is_none());
1616//! ```
Original file line number Diff line number Diff line change @@ -10,6 +10,16 @@ pub struct Mime {
1010 pub parameters : Vec < ( String , String ) >
1111}
1212
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+
1323#[ derive( Debug ) ]
1424pub struct MimeParsingError ( ( ) ) ;
1525
You can’t perform that action at this time.
0 commit comments