2
1
Fork 0

typegen: add more .,:; as reference shorthand separators

This commit is contained in:
outfoxxed 2024-07-21 14:31:12 -07:00
parent 3fe7cf9bf9
commit 8caead7505
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -647,13 +647,25 @@ fn parse_details(comment: Comment) -> String {
accum += &src[..i];
src = &src[i + 2..];
let endmk = src.find('$');
let endsp = src.find(' ');
let separators = [
('$', true),
(' ', false),
('.', false),
(',', false),
(';', false),
(':', false),
];
let (end, ty) = match (endmk, endsp) {
(Some(i), _) if i < endsp.unwrap_or(usize::MAX) => (i + 1, &src[..i]),
(_, Some(i)) => (i, &src[..i]),
_ => (src.len(), src),
let mut chars = src.chars().enumerate();
let (end, ty) = loop {
match chars.next() {
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));