named_item/history.rs
1crate::ix!();
2
3/// Provides a history of names an item has had.
4pub trait NameHistory {
5 /// Adds a name to the history.
6 fn add_name_to_history(&mut self, name: &str);
7
8 /// Returns the history of names.
9 fn name_history(&self) -> Vec<Cow<'_, str>>;
10}
11
12/// Trait for setting the name while maintaining a history of changes.
13pub trait SetNameWithHistory: SetName + NameHistory {
14 /// Sets the name and records the change in the name history.
15 fn set_name_with_history(&mut self, name: &str) -> Result<(), NameError> {
16 self.add_name_to_history(name);
17 self.set_name(name)
18 }
19}