Last active
August 29, 2015 14:06
-
-
Save globin/824dd836266f95bbd56e to your computer and use it in GitHub Desktop.
FromIterator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn packagist_versions_from_json<'a>(&self, json: &'a Json) -> Option<Version> { | |
json.find_path(&[&"package".to_string(), &"versions".to_string()]) | |
.and_then(|versions_json| versions_json.as_object()) | |
.and_then(|versions_map| { | |
versions_map.keys().map(|version_string| { | |
println!("version {}, {}", version_string, Version::parse(version_string.as_slice())); | |
Version::parse(version_string.as_slice()).ok() | |
}).fold(None, |a, b| { | |
match (a, b) { | |
(None, b@_) => b, | |
(a@Some(_), None) => a, | |
(Some(a), Some(b)) => Some(max(a, b)) | |
} | |
}) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/home/robin/dev/rust-composer-check/src/main.rs:74:17: 81:28 error: the trait `core::iter::FromIterator<semver::version::Version>` is not implemented for the type `semver::version::Version` | |
/home/robin/dev/rust-composer-check/src/main.rs:74 versions_map.values().map(|version_json| | |
/home/robin/dev/rust-composer-check/src/main.rs:75 version_json.find(&"version".to_string()) | |
/home/robin/dev/rust-composer-check/src/main.rs:76 .and_then(|version_json_string| version_json_string.as_string()) | |
/home/robin/dev/rust-composer-check/src/main.rs:77 .and_then(|version_string| { | |
/home/robin/dev/rust-composer-check/src/main.rs:78 println!("version {}, {}", version_string, Version::parse(version_string)) | |
/home/robin/dev/rust-composer-check/src/main.rs:79 Version::parse(version_string).ok() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment