Crates.io | txt_writer |
lib.rs | txt_writer |
version | 0.1.4 |
source | src |
created_at | 2022-09-01 21:26:06.606781 |
updated_at | 2022-09-12 21:29:39.524181 |
description | Easier and faster way to write txt files in rust |
homepage | https://carghaiwebsite.web.app/#/ |
repository | https://github.com/carghai/txt_writer |
max_upload_size | |
id | 657030 |
size | 9,242 |
This package allows you to write and read txt file with one line of code, rather then having to waste time and write 10-50 lines of code!
There are two ways to read a file. One reads a file line by line(read), one reads it as a string (read_one).
fn main() {
let data = txt_writer::ReadData {}
.read("path to your txt".to_string())
.expect("failed when reading");
for x in data {
println!("{}", x);
}
}
fn main() {
let data = txt_writer::ReadData {}
.read_one("path to your txt".to_string())
.expect("failed when reading");
println!("{}", data);
}
There are 2 ways to write data. If you want to create a txt OR overwrite data use this.
fn main() {
txt_writer::WriteData {}
.replace(
"what you want to write to txt".to_string(),
"path to your txt".to_string(),
)
.expect("failed when writing");
}
NOTE THIS FUNCTION WILL RETURN AN ERROR IF THE TXT DOES NOT EXIST
fn main(){
txt_writer::WriteData {}
.add(
"what you want to write to txt".to_string(),
"path to your txt".to_string(),
)
.expect("failed when writing");
}
use txt_writer;
fn main() {
txt_writer::WriteData {}
.replace(
&"what you want to write to txt".to_string(),
"src/data.txt".to_string(),
)
.expect("failed when writing");
txt_writer::WriteData {}
.add(
&"what you want to write to txt".to_string(),
"src/data.txt".to_string(),
)
.expect("failed when writing");
let data = txt_writer::ReadData {}
.read("src/data.txt".to_string())
.expect("failed when reading");
for x in data {
println!("{}", x);
}
let data = txt_writer::ReadData {}
.read_one("src/data.txt".to_string())
.expect("failed when reading");
println!("{}", data);
}