Redirect AllOrSome<HashSet<Url>>::new_from_str_list
This commit is contained in:
parent
a5f54c72cf
commit
87e4145493
13
src/lib.rs
13
src/lib.rs
|
@ -471,18 +471,7 @@ impl AllOrSome<HashSet<Url>> {
|
|||
/// and the second element
|
||||
/// is a map of strings which failed to parse into URLs and their associated parse errors.
|
||||
pub fn new_from_str_list(urls: &[&str]) -> (Self, HashMap<String, url::ParseError>) {
|
||||
let (ok_set, error_map): (Vec<_>, Vec<_>) = urls.iter()
|
||||
.map(|s| (s.to_string(), Url::from_str(s)))
|
||||
.partition(|&(_, ref r)| r.is_ok());
|
||||
|
||||
let error_map = error_map
|
||||
.into_iter()
|
||||
.map(|(s, r)| (s.to_string(), r.unwrap_err()))
|
||||
.collect();
|
||||
|
||||
let ok_set = ok_set.into_iter().map(|(_, r)| r.unwrap()).collect();
|
||||
|
||||
(AllOrSome::Some(ok_set), error_map)
|
||||
AllowedOrigins::some(urls)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue