use super::dropdown::DropdownItem;
#[derive(Clone, Debug)]
pub struct FileItem {
pub path: String,
pub is_dir: bool,
}
impl DropdownItem for FileItem {
fn label(&self) -> &str {
&self.path
}
fn description(&self) -> String {
if self.is_dir {
"\u{1f4c1}".to_string() } else {
String::new()
}
}
fn matches_filter(&self, _filter: &str) -> bool {
true
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn dir_shows_icon() {
let item = FileItem {
path: "src/".into(),
is_dir: true,
};
assert!(!item.description().is_empty());
}
#[test]
fn file_no_description() {
let item = FileItem {
path: "main.rs".into(),
is_dir: false,
};
assert!(item.description().is_empty());
}
}