INNER CODE UNIT · Rust
add_text
CleanCut/rusty_engine · src/game.rs:131
pub fn add_text<T, S>(&mut self, label: T, text: S) -> &mut Text
where
T: Into<String>,
S: Into<String>,
{
let label = label.into();
let text = text.into();
let curr_text = Text {
label: label.clone(),
value: text,
..Default::default()
};
self.texts.insert(label.clone(), curr_text);
// Unwrap: Can't crash because we just inserted the text
self.texts.get_mut(&label).unwrap()
}
}