mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 22:18:33 +00:00
property: fix short type name calculation
This commit is contained in:
parent
0a348af630
commit
941e441f32
1 changed files with 13 additions and 5 deletions
|
@ -91,11 +91,19 @@ impl PropertyTypeRegistration {
|
|||
}
|
||||
|
||||
pub fn get_short_name(full_name: &str) -> String {
|
||||
full_name
|
||||
.split("<")
|
||||
.map(|p| p.split("::").last().unwrap())
|
||||
.collect::<Vec<&str>>()
|
||||
.join("<")
|
||||
let mut split = full_name.splitn(2, "<");
|
||||
|
||||
// main type
|
||||
let mut short_name = split.next().unwrap().split("::").last().unwrap().to_string();
|
||||
|
||||
// process generics if they exist
|
||||
if let Some(generics) = split.next() {
|
||||
let generics = generics.strip_suffix(">").expect("should end with closing carrot");
|
||||
short_name.push('<');
|
||||
short_name.push_str(&generics.split(',').map(|generic| Self::get_short_name(generic.trim())).collect::<Vec<String>>().join(", "));
|
||||
short_name.push('>');
|
||||
}
|
||||
short_name
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D>(
|
||||
|
|
Loading…
Add table
Reference in a new issue