Redirect AllOrSome<HashSet<Url>>::new_from_str_list

This commit is contained in:
Yong Wen Chua 2017-07-19 12:33:02 +08:00
parent a5f54c72cf
commit 87e4145493
1 changed files with 1 additions and 12 deletions

View File

@ -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)
}
}