greattraits

Crates.iogreattraits
lib.rsgreattraits
version0.1.0
sourcesrc
created_at2024-09-14 11:11:31.815822
updated_at2024-09-14 11:11:31.815822
descriptionMy own collection for traits extending standard library types
homepage
repositoryhttps://github.com/denizsincar29/greattraits
max_upload_size
id1374688
size6,122
Deniz Sincar (denizsincar29)

documentation

README

greattraits

A collection of great traits extending rust's standard library.

Traits

For now, this collection includes only one trait, but I plan to add more in the future.

Pathjects:

A trait for path manipulation. (only Path, but want to extend to PathBuf). It supports several methods to open a file, delete a file, create, as well as open in bufread and bufwrite mode.

Usage

Use a simple shell command to install the crate:

cargo add greattraits

Then, you can use the trait in your code:

use greattraits::Pathjects;

fn main(){
    let folder = Path::new("myfolder");
    folder.mkdir().expect("cannot create folder");
    let txt=folder.join("hello.txt");
    let mut f=txt.create().expect("cannot create file");
    write!(f, "hello!").expect("cannot write file");
    txt.delete().expect("can't delete!");
    folder.delete().expect("can't delete folder!");
}

License

This is my hobby project and i'm still not knowledgeable about licensing. But someone told me that MIT is a good license, so I'm using it. If you have any suggestions, please let me know.

Commit count: 0

cargo fmt