fix: fix sedre issue · inherd/uncode@49ddb2b · GitHub
Skip to content

Commit 49ddb2b

Browse files
committed
fix: fix sedre issue
1 parent 39edab5 commit 49ddb2b

4 files changed

Lines changed: 28 additions & 8 deletions

File tree

‎src-tauri/src/main.rs‎

Lines changed: 1 addition & 1 deletion

‎uncode/uncode-core/Cargo.toml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ exclude = [
2323
]
2424

2525
[dependencies]
26-
# serial
27-
serde = { version = "1.0" }
28-
serde_json = { version = "1.0" }
26+
serde = { version = "1.0", features = ["derive"] }
27+
serde_json = "1.0"

‎uncode/uncode-core/src/file_entry.rs‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ impl Default for FileEntry {
2525
}
2626
}
2727

28+
#[allow(dead_code)]
2829
impl FileEntry {
29-
pub fn from_path(path: PathBuf) -> Self {
30+
/// create a simple FileEntry
31+
fn from_path(path: PathBuf) -> Self {
3032
let file_name = path.file_name().unwrap();
3133
let name = match file_name.to_str() {
3234
None => "".to_string(),
@@ -58,7 +60,7 @@ impl FileEntry {
5860
}
5961
}
6062

61-
pub fn add_child(mut self, child: Self) -> Self {
63+
fn add_child(mut self, child: Self) -> Self {
6264
self.children.push(child);
6365
self
6466
}
@@ -84,9 +86,16 @@ impl FileEntry {
8486
.unwrap_or(false)
8587
}
8688

87-
pub fn from_dir(title: String, dir: &Path) -> FileEntry {
89+
/// Returns FileEntry with the given path.
90+
///
91+
/// # Arguments
92+
///
93+
/// * `title` - default path name
94+
/// * `path` - CODE PATH
95+
///
96+
pub fn by_dir(title: String, path: &Path) -> FileEntry {
8897
let mut root = FileEntry::new(title);
89-
let _result = FileEntry::visit_dirs(dir, 0, &mut root, dir);
98+
let _result = FileEntry::visit_dirs(path, 0, &mut root, path);
9099
root
91100
}
92101

@@ -132,3 +141,14 @@ impl FileEntry {
132141
}
133142
}
134143

144+
#[cfg(test)]
145+
mod tests {
146+
use std::path::PathBuf;
147+
use crate::file_entry::FileEntry;
148+
149+
#[test]
150+
fn should_support_for_visitor_by_level() {
151+
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
152+
FileEntry::by_dir("root".to_string(), &path);
153+
}
154+
}

‎uncode/uncode-core/src/lib.rs‎

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)