I am getting confused with some code from Rust but I am managing it. But I have problem in understanding how the function iter()
work in Rust. What is the possible result for a String?
Edit
impl Selector {
pub fn specificity(&self) -> Specificity {
// http://www.w3.org/TR/selectors/#specificity
let Selector::Simple(ref simple) = *self;
let a = simple.id.iter().len();
let b = simple.class.len();
let c = simple.tag_name.iter().len();
(a, b, c)
}
}
Where simple.id
is string
.
You seem to be referencing code from Robinson, specifically this file.
Note that
SimpleSelector
is defined as:So
id
is not aString
, but anOption<String>
.iter
onOption
is defined as:This allows you to write code that will happen if the value is
Some
and will not happen if it isNone
.