~matthiasbeyer/imag

05051ba38393253c41c8832d45efe53c1559eec7 — Matthias Beyer 1 year, 10 months ago d381a59
Fix: Use unwrap_or_else(panic!(...)) as recommended by clippy

instead of expect()ing errors, clippy suggests to use
unwrap_or_else(|| panic!(...)) - use that instead

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
1 files changed, 4 insertions(+), 4 deletions(-)

M tests/version-sync/src/lib.rs
M tests/version-sync/src/lib.rs => tests/version-sync/src/lib.rs +4 -4
@@ 70,8 70,8 @@ fn test_all_cargotoml_files() {
            None
        })
        .for_each(|cargotoml| {
            let filecontent = std::fs::read_to_string(&cargotoml).expect(&format!("Failed to read {}", cargotoml.display()));
            let toml = filecontent.parse::<Value>().expect(&format!("Failed to parse toml: {}", cargotoml.display()));
            let filecontent = std::fs::read_to_string(&cargotoml).unwrap_or_else(|_| panic!("Failed to read {}", cargotoml.display()));
            let toml = filecontent.parse::<Value>().unwrap_or_else(|_| panic!("Failed to parse toml: {}", cargotoml.display()));

            match toml.get("dependencies") {
                Some(Value::Table(ref tab)) => {


@@ 80,7 80,7 @@ fn test_all_cargotoml_files() {
                            match v {
                                Value::String(s) => assert!(s.contains(current_version)),
                                Value::Table(ref dep) => {
                                    let version = dep.get("version").expect(&format!("No 'version' key for dependencies at {}", cargotoml.display()));
                                    let version = dep.get("version").unwrap_or_else(|| panic!("No 'version' key for dependencies at {}", cargotoml.display()));
                                    let version_str = version.as_str().unwrap();
                                    assert!(version_str.contains(current_version), "failed for: {} ('{}')", cargotoml.display(), version_str)
                                },


@@ 100,7 100,7 @@ fn test_all_cargotoml_files() {
                            match v {
                                Value::String(s) => assert!(s.contains(current_version)),
                                Value::Table(ref dep) => {
                                    let version = dep.get("version").expect(&format!("No 'version' key for dev-dependencies at {}", cargotoml.display()));
                                    let version = dep.get("version").unwrap_or_else(|| panic!("No 'version' key for dev-dependencies at {}", cargotoml.display()));
                                    let version_str = version.as_str().unwrap();
                                    assert!(version_str.contains(current_version), "failed for: {} ('{}')", cargotoml.display(), version_str)
                                },