Clean up broken tests and clippy warnings
This commit is contained in:
parent
ee348c29cb
commit
66876e41c0
|
@ -244,7 +244,7 @@ mod test {
|
||||||
let tmp = TempDir::new("var").unwrap();
|
let tmp = TempDir::new("var").unwrap();
|
||||||
let handle =
|
let handle =
|
||||||
FileHandle::new("rawr.png".to_owned(), PathBuf::from(tmp.path())).expect("to succeed");
|
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.size, 0);
|
||||||
assert_eq!(handle.info.file_type, "image/png");
|
assert_eq!(handle.info.file_type, "image/png");
|
||||||
assert_eq!(handle.info.extension, "png");
|
assert_eq!(handle.info.extension, "png");
|
||||||
|
|
|
@ -9,18 +9,13 @@ use std::{
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub enum Tree<T> {
|
pub enum Tree<T> {
|
||||||
|
#[default]
|
||||||
Empty,
|
Empty,
|
||||||
Root(Node<T>),
|
Root(Node<T>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Default for Tree<T> {
|
|
||||||
fn default() -> Self {
|
|
||||||
Tree::Empty
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Tree<T> {
|
impl<T> Tree<T> {
|
||||||
pub fn new(value: T) -> (Tree<T>, Node<T>) {
|
pub fn new(value: T) -> (Tree<T>, Node<T>) {
|
||||||
let node = Node::new(value);
|
let node = Node::new(value);
|
||||||
|
@ -129,14 +124,14 @@ impl<T> Node<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Immutably retrieve the data in this node.
|
/// 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
|
// 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
|
// maybe to avoid conflicting with other `map` declarations. Why that is necessary when
|
||||||
// Option::map exists as a member, I don't know.
|
// Option::map exists as a member, I don't know.
|
||||||
Ref::map(self.0.borrow(), |v| &v.value)
|
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)
|
Ref::map(self.0.borrow(), |v| &v.children)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue