Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Nov 1, 2024
1 parent 83560a0 commit 6dbd658
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/wasm/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,19 @@ pub struct Entity(pub HashMap<String, Model>);
impl From<&torii_grpc::types::schema::Entity> for Entity {
fn from(value: &torii_grpc::types::schema::Entity) -> Self {
let mut seen_models = HashMap::new();
Self(value.models.iter().map(|m| {
let count = seen_models.entry(m.name.clone()).or_insert(0);
let name = if *count == 0 {
m.name.clone()
} else {
format!("{}-{}", m.name, count)
};
*count += 1;
(name, m.into())
}).collect())
Self(
value
.models
.iter()
.map(|m| {
let count = seen_models.entry(m.name.clone()).or_insert(0);
let name =
if *count == 0 { m.name.clone() } else { format!("{}-{}", m.name, count) };
*count += 1;
(name, m.into())
})
.collect(),
)
}
}

Expand Down

0 comments on commit 6dbd658

Please sign in to comment.