remove clippy messages to clean code
This commit is contained in:
@@ -26,7 +26,7 @@ fn get_value(iter: &mut TokenTreeIter) -> Option<String> {
|
||||
}
|
||||
|
||||
impl YaSerdeAttribute {
|
||||
pub fn parse(attrs: &Vec<Attribute>) -> YaSerdeAttribute {
|
||||
pub fn parse(attrs: &[Attribute]) -> YaSerdeAttribute {
|
||||
let mut attribute = false;
|
||||
let mut namespaces = BTreeMap::new();
|
||||
let mut prefix = None;
|
||||
@@ -36,59 +36,54 @@ impl YaSerdeAttribute {
|
||||
|
||||
for attr in attrs.iter() {
|
||||
let mut attr_iter = attr.clone().tts.into_iter();
|
||||
match attr_iter.next() {
|
||||
Some(token) => match token.kind {
|
||||
Group(Parenthesis, token_stream) => {
|
||||
let mut attr_iter = token_stream.into_iter();
|
||||
if let Some(token) = attr_iter.next() {
|
||||
if let Group(Parenthesis, token_stream) = token.kind {
|
||||
let mut attr_iter = token_stream.into_iter();
|
||||
|
||||
while let Some(item) = attr_iter.next() {
|
||||
match item.kind {
|
||||
Term(t) => match t.as_str() {
|
||||
"attribute" => {
|
||||
attribute = true;
|
||||
}
|
||||
"namespace" => {
|
||||
if let Some(namespace) = get_value(&mut attr_iter) {
|
||||
let splitted: Vec<&str> = namespace.split(": ").collect();
|
||||
if splitted.len() == 2 {
|
||||
namespaces.insert(splitted[0].to_owned(), splitted[1].to_owned());
|
||||
}
|
||||
if splitted.len() == 1 {
|
||||
namespaces.insert("".to_owned(), splitted[0].to_owned());
|
||||
}
|
||||
while let Some(item) = attr_iter.next() {
|
||||
if let Term(term) = item.kind {
|
||||
match term.as_str() {
|
||||
"attribute" => {
|
||||
attribute = true;
|
||||
}
|
||||
"namespace" => {
|
||||
if let Some(namespace) = get_value(&mut attr_iter) {
|
||||
let splitted: Vec<&str> = namespace.split(": ").collect();
|
||||
if splitted.len() == 2 {
|
||||
namespaces.insert(splitted[0].to_owned(), splitted[1].to_owned());
|
||||
}
|
||||
if splitted.len() == 1 {
|
||||
namespaces.insert("".to_owned(), splitted[0].to_owned());
|
||||
}
|
||||
}
|
||||
"prefix" => {
|
||||
prefix = get_value(&mut attr_iter);
|
||||
}
|
||||
"rename" => {
|
||||
rename = get_value(&mut attr_iter);
|
||||
}
|
||||
"root" => {
|
||||
root = get_value(&mut attr_iter);
|
||||
}
|
||||
"text" => {
|
||||
text = true;
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
}
|
||||
"prefix" => {
|
||||
prefix = get_value(&mut attr_iter);
|
||||
}
|
||||
"rename" => {
|
||||
rename = get_value(&mut attr_iter);
|
||||
}
|
||||
"root" => {
|
||||
root = get_value(&mut attr_iter);
|
||||
}
|
||||
"text" => {
|
||||
text = true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
YaSerdeAttribute {
|
||||
attribute: attribute,
|
||||
namespaces: namespaces,
|
||||
prefix: prefix,
|
||||
rename: rename,
|
||||
root: root,
|
||||
text: text,
|
||||
attribute,
|
||||
namespaces,
|
||||
prefix,
|
||||
rename,
|
||||
root,
|
||||
text,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user