pub fn prefix_matches(prefix: &str, request_path: &str) -> bool { //split by slash and change element into Option and add None at the end. let mut prefixs = prefix.split("/").map(|p| Some(p)).chain(std::iter::once(None)); let mut request_paths = request_path.split("/").map(|p| Some(p)).chain(std::iter::once(None)); //matching every two element for (prefix, path) in prefixs.zip(request_paths) { match (prefix, path) { (Some(prefix), Some(path)) => { if prefix != "*" && prefix != path { return false; } } (Some(_), None) => return false, (None, Some(_)) => break, (None, None) => break, } } true }标签:None,day2,comprehensive,Some,request,prefix,split,path,rust From: https://www.cnblogs.com/johnnyzhao/p/17004843.html