typegen: add more .,:; as reference shorthand separators
This commit is contained in:
parent
3fe7cf9bf9
commit
8caead7505
|
@ -647,13 +647,25 @@ fn parse_details(comment: Comment) -> String {
|
||||||
accum += &src[..i];
|
accum += &src[..i];
|
||||||
src = &src[i + 2..];
|
src = &src[i + 2..];
|
||||||
|
|
||||||
let endmk = src.find('$');
|
let separators = [
|
||||||
let endsp = src.find(' ');
|
('$', true),
|
||||||
|
(' ', false),
|
||||||
|
('.', false),
|
||||||
|
(',', false),
|
||||||
|
(';', false),
|
||||||
|
(':', false),
|
||||||
|
];
|
||||||
|
|
||||||
let (end, ty) = match (endmk, endsp) {
|
let mut chars = src.chars().enumerate();
|
||||||
(Some(i), _) if i < endsp.unwrap_or(usize::MAX) => (i + 1, &src[..i]),
|
let (end, ty) = loop {
|
||||||
(_, Some(i)) => (i, &src[..i]),
|
match chars.next() {
|
||||||
_ => (src.len(), src),
|
Some((i, c)) => {
|
||||||
|
if let Some(strip) = separators.iter().filter(|(sc, _)| c == *sc).map(|(_, strip)| *strip).next() {
|
||||||
|
break (i + if strip { 1 } else { 0 }, &src[..i]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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