Refactor macro handling: add pascal_to_snake utility, rewrite Target handling, and update descriptor structure for bits-based targets.
This commit is contained in:
@@ -24,3 +24,26 @@ pub fn snake_to_title(s: &str) -> String
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ")
|
||||
}
|
||||
|
||||
pub fn pascal_to_snake(s: &str) -> String
|
||||
{
|
||||
let mut out = String::with_capacity(s.len());
|
||||
let mut prev_lower = false;
|
||||
|
||||
for c in s.chars()
|
||||
{
|
||||
if c.is_uppercase()
|
||||
{
|
||||
if prev_lower { out.push('_'); }
|
||||
for lc in c.to_lowercase() { out.push(lc); }
|
||||
prev_lower = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev_lower = true;
|
||||
out.push(c);
|
||||
}
|
||||
}
|
||||
|
||||
out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user