I wanted to continue modify func in book about rust,original func:
fn parse_pair<T: FromStr>(s : &str, separator :char) -> Option<(T,T)>{
match s.find(separator){
None => None,
Some(index) => {
match (T::from_str(&s[..index]), T::from_str(&s[index+1..])){
(Ok(l),Ok(r)) => Some((l, r)),
_ => None
}
}
}
}
My(I want to parse insted 2, three arguments) but where //1ая ветка as i suppose find the same separator,thanks)
fn parse_three<T: FromStr>(s : &str, separator :char) -> Option<(T,T,T)>{
match s.find(separator){
None => None,
Some(index) => {
match s[index+1..].find(separator){//1ая ветка
None => match (T::from_str(&s[..index]), T::from_str(&s[index+1..])){
(Ok(_l),Ok(_r)) => None, //Some((l, r,None)),
_ => None
},
Some(indexx) =>{//вторая ветка
match (T::from_str(&s[..index]), T::from_str(&s[index+1..indexx]),T::from_str(&s[indexx+1..])){
(Ok(l),Ok(r),Ok(c)) =>
Some((l, r,c)),
_ => None
}
}
}
}
}
}
Also question:if i want new value
let dx = (domain.1-domain.0)/steps
where dsteps is usize, and numerator isize maybe, or f32 ... Compiler has complained,but logically all is right,i want to divide on number)