Crates.io | custom_codes |
lib.rs | custom_codes |
version | 2.0.4 |
source | src |
created_at | 2019-07-05 06:46:41.307125 |
updated_at | 2020-07-31 07:18:05.425668 |
description | Simple uniform response and error codes backed by enums |
homepage | https://github.com/charleschege/custom_codes |
repository | https://github.com/charleschege/custom_codes |
max_upload_size | |
id | 146437 |
size | 55,425 |
This are Custom Enums
for memorable and uniform response codes.
Enums are cheaper to compare and harder to get wrong than strings thereby guaranteeing efficiency.
use custom_codes::FileOps;
fn create_file(file_name: &str) -> FileOps {
match std::fs::File::create(file_name) {
Ok(_) => FileOps::CreateTrue,
Err(_) => FileOps::CreateFalse,
}
}
fn main() {
open("foo.txt");
}