Adding and moving a lot of components.

This is the main thrust of the library. I know it is a lot of changes,
but I was running out of time and had to hammer them all in.
This commit is contained in:
2025-09-24 19:50:38 -04:00
parent f752fa17bf
commit 8f61185434
15 changed files with 558 additions and 545 deletions

37
bard/src/togglable.rs Normal file
View File

@ -0,0 +1,37 @@
use std::collections::HashSet;
/// Trait to toggle the presence of a value (like a tag) in a set.
pub trait Togglable
{
type Item: ?Sized;
fn toggle(&mut self, item: &Self::Item);
fn is_toggled(&self, item: &Self::Item) -> bool;
}
impl Togglable for HashSet<String>
{
type Item = str;
fn toggle(&mut self, item: &str)
{
if self.contains(item)
{
self.remove(item);
}
else
{
self.insert(item.to_owned());
}
}
fn is_toggled(&self, item: &str) -> bool
{
self.contains(item)
}
}