typegen: make reference sep parser more idiomatic
This commit is contained in:
parent
8caead7505
commit
fe17f4adbb
|
@ -656,17 +656,13 @@ fn parse_details(comment: Comment) -> String {
|
||||||
(':', false),
|
(':', false),
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut chars = src.chars().enumerate();
|
let (end, ty) = src.chars().enumerate()
|
||||||
let (end, ty) = loop {
|
.find_map(|(i, char)| {
|
||||||
match chars.next() {
|
separators.iter()
|
||||||
Some((i, c)) => {
|
.find(|(sc, _)| char == *sc)
|
||||||
if let Some(strip) = separators.iter().filter(|(sc, _)| c == *sc).map(|(_, strip)| *strip).next() {
|
.map(|(_, strip)| (i + if *strip { 1 } else { 0 }, &src[..i]))
|
||||||
break (i + if strip { 1 } else { 0 }, &src[..i]);
|
})
|
||||||
}
|
.unwrap_or_else(|| (src.len(), src));
|
||||||
},
|
|
||||||
None => break (src.len(), src),
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut split = ty.rsplit_once('.').unwrap_or(("", ty));
|
let mut split = ty.rsplit_once('.').unwrap_or(("", ty));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue