Clean up broken tests and clippy warnings

pull/80/head
Savanni D'Gerinel 2023-10-25 10:35:24 -04:00
parent ee348c29cb
commit 66876e41c0
2 changed files with 5 additions and 10 deletions

View File

@ -244,7 +244,7 @@ mod test {
let tmp = TempDir::new("var").unwrap();
let handle =
FileHandle::new("rawr.png".to_owned(), PathBuf::from(tmp.path())).expect("to succeed");
assert_eq!(handle.info.name, Some("rawr".to_owned()));
assert_eq!(handle.info.name, "rawr");
assert_eq!(handle.info.size, 0);
assert_eq!(handle.info.file_type, "image/png");
assert_eq!(handle.info.extension, "png");

View File

@ -9,18 +9,13 @@ use std::{
rc::Rc,
};
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Default)]
pub enum Tree<T> {
#[default]
Empty,
Root(Node<T>),
}
impl<T> Default for Tree<T> {
fn default() -> Self {
Tree::Empty
}
}
impl<T> Tree<T> {
pub fn new(value: T) -> (Tree<T>, Node<T>) {
let node = Node::new(value);
@ -129,14 +124,14 @@ impl<T> Node<T> {
}
/// Immutably retrieve the data in this node.
pub fn value<'a>(&self) -> Ref<T> {
pub fn value(&self) -> Ref<T> {
// Ref::map is not actually a member function. I don't know why this was done, other than
// maybe to avoid conflicting with other `map` declarations. Why that is necessary when
// Option::map exists as a member, I don't know.
Ref::map(self.0.borrow(), |v| &v.value)
}
pub fn children<'a>(&self) -> Ref<Vec<Node<T>>> {
pub fn children(&self) -> Ref<Vec<Node<T>>> {
Ref::map(self.0.borrow(), |v| &v.children)
}