diff --git a/Cargo.lock b/Cargo.lock index eb8fa07..7ca79b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,7 @@ checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" [[package]] name = "holocal" -version = "0.1.4" +version = "0.1.5" dependencies = [ "quick-xml", "reqwest", diff --git a/Cargo.toml b/Cargo.toml index f40ef22..0df3a9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "holocal" -version = "0.1.4" +version = "0.1.5" authors = ["blank X "] edition = "2018" diff --git a/src/main.rs b/src/main.rs index 988c225..8ec2e92 100644 --- a/src/main.rs +++ b/src/main.rs @@ -82,14 +82,14 @@ fn main() { loop { match reader.read_event(&mut buf) { Ok(Event::Start(ref e)) => { - match String::from_utf8(e.name().to_vec()).unwrap().as_str() { - "item" => { + match e.name() { + b"item" => { is_inside_item = true; title = None; url = None; }, - "title" => is_inside_title = true, - "description" => is_inside_description = true, + b"title" => is_inside_title = true, + b"description" => is_inside_description = true, _ => () }; }, @@ -106,9 +106,9 @@ fn main() { loop { match description_reader.read_event(&mut description_buf) { Ok(Event::Empty(ref e)) => { - if String::from_utf8(e.name().to_vec()).unwrap().as_str() == "img" { + if e.name() == b"img" { url = Some(e.attributes() - .find(|attribute| String::from_utf8(attribute.as_ref().unwrap().key.to_vec()).unwrap().as_str() == "src") + .find(|attribute| attribute.as_ref().unwrap().key == b"src") .unwrap() .unwrap() .unescape_and_decode_value(&description_reader) @@ -123,20 +123,20 @@ fn main() { } }, Ok(Event::End(ref e)) => { - match String::from_utf8(e.name().to_vec()).unwrap().as_str() { - "item" => { + match e.name() { + b"item" => { is_inside_item = false; if title.is_some() && url.is_some() { break; } }, - "description" => { + b"description" => { is_inside_description = false; if title.is_some() && url.is_some() { break; } }, - "title" => is_inside_title = false, + b"title" => is_inside_title = false, _ => () }; },