util-easy 0.1.0

Small utility helpers for common tasks.
Documentation
  • Coverage
  • 100%
    6 out of 6 items documented0 out of 4 items with examples
  • Size
  • Source code size: 20.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 270.96 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • tw-libraries/rust/util-easy
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • T-Welsh

util-easy

Small utility helpers for common tasks.

Installation

Add this to your Cargo.toml:

[dependencies]
util-easy = "0.1.0"

Filesystem Helpers

util_easy::fs provides small wrappers around common filesystem operations:

  • ensure_dir_exists(path) creates a directory and its parents if needed.
  • ensure_parent_dir_exists(path) creates the parent directory for a file path if needed.
  • remove_file_if_exists(path) removes a file and succeeds if it is already missing.
  • remove_dir_all_if_exists(path) removes a directory recursively and succeeds if it is already missing.
use util_easy::fs::{ensure_parent_dir_exists, remove_file_if_exists};

fn main() -> std::io::Result<()> {
    let path = "output/example.txt";

    ensure_parent_dir_exists(path)?;
    std::fs::write(path, "hello")?;

    remove_file_if_exists(path)?;

    Ok(())
}

License

Licensed under either of:

  • Apache License, Version 2.0
  • MIT license

at your option.