A collection of reusable utilities for Rust projects.
This library provides a set of modules to simplify common tasks in Rust applications.
collections: Extends collections withcontains,contains_predicate, andfirstmethods.result: Adds ato_resultmethod toboolfor easy conversion to aResult.
errors: Defines a commonCommonsErrorenum for handling I/O and environment variable errors.
datetime_util: Functions for working with dates and times, including getting the current date, timestamp, and formattingSystemTime.file_util: Utilities for reading, writing, deleting, and copying files and directories.hash_util: Functions for generating SHA256 hashes for strings and files, and for creating unique IDs.path_util: Utilities for expanding the home directory (~) in paths and getting the home directory path.shell_util: Functions for executing shell commands.string_util: A utility for finding the minimum unique prefix of a string within a list of strings.
Add this to your Cargo.toml:
[dependencies]
commons = "0.2.6"Then, you can use the utilities in your code:
use commons::utils::file_util;
fn main() {
let content = file_util::read_file("path/to/your/file.txt").unwrap();
println!("{}", content);
}Contributions are welcome! Please feel free to submit a pull request.
This project is licensed under the MIT License.