Skip to content

Commit 7570c33

Browse files
committed
feat(paths): add is_empty method to check if Paths collection is empty
1 parent 0243fe7 commit 7570c33

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

src/lib.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,14 @@
8989
//! ```rust
9090
//! use framels::{basic_listing, extended_listing, parse_dir, paths::{Paths,Join}, recursive_dir};
9191
//!
92-
//! fn main() {
93-
//! // Perform directory listing
94-
//! let in_paths: Paths = parse_dir("./samples/small");
92+
//!
93+
//! // Perform directory listing
94+
//! let in_paths: Paths = parse_dir("./samples/small");
9595
//!
96-
//! // Generate results based on arguments
96+
//! // Generate results based on arguments
9797
//! let results: String = basic_listing(in_paths, false).get_paths().join("\n");
9898
//!
9999
//! println!("{}", results)
100-
//! }
101100
//! ```
102101
mod exr_metadata;
103102
pub mod paths;
@@ -307,15 +306,13 @@ fn create_frame_string(value: Vec<String>) -> String {
307306
/// ```rust
308307
/// use framels::{basic_listing, parse_dir, paths::{Paths,Join}};
309308
///
310-
/// fn main() {
311-
/// // Perform directory listing
312-
/// let in_paths: Paths = parse_dir("./samples/small");
309+
/// // Perform directory listing
310+
/// let in_paths: Paths = parse_dir("./samples/small");
313311
///
314-
/// // Generate results based on arguments
315-
/// let results: String = basic_listing(in_paths, false).get_paths().join("\n");
312+
/// // Generate results based on arguments
313+
/// let results: String = basic_listing(in_paths, false).get_paths().join("\n");
316314
///
317-
/// println!("{}", results)
318-
/// }
315+
/// println!("{}", results)
319316
/// ```
320317
pub fn basic_listing(frames: Paths, multithreaded: bool) -> PathsPacked {
321318
let frames_dict: HashMap<String, Vec<String>> = parse_result(frames, multithreaded);

src/paths.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,27 @@ impl Paths {
7676
pub fn len(&self) -> usize {
7777
self.data.len()
7878
}
79+
/// # is_empty
80+
///
81+
/// ## Description
82+
///
83+
/// Return true if the paths collection is empty, false otherwise
84+
///
85+
/// ## Example
86+
///
87+
/// ```rust
88+
/// use framels::paths::Paths;
89+
/// use std::path::PathBuf;
90+
///
91+
/// let empty_paths = Paths::from(vec![]);
92+
/// assert_eq!(empty_paths.is_empty(), true);
93+
///
94+
/// let paths = Paths::from(vec![PathBuf::from("foo")]);
95+
/// assert_eq!(paths.is_empty(), false);
96+
/// ```
97+
pub fn is_empty(&self) -> bool {
98+
self.data.is_empty()
99+
}
79100
/// # iter
80101
///
81102
/// ## Description

0 commit comments

Comments
 (0)