Crates.io | xerr |
lib.rs | xerr |
version | 0.1.14 |
source | src |
created_at | 2023-09-11 06:33:22.223563 |
updated_at | 2024-06-13 10:19:57.970271 |
description | log error util |
homepage | https://github.com/i18n-site/rust/tree/main/xerr |
repository | https://github.com/i18n-site/rust.git |
max_upload_size | |
id | 969295 |
size | 3,465 |
use std::io::Read;
use xerr::ok_or;
pub fn size(path: &str) -> usize {
ok_or!(
{
let mut s = String::new();
std::fs::File::open(path)?.read_to_string(&mut s)?;
s.len()
},
0
)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test() {
loginit::init();
let result = size("not exist");
assert_eq!(result, 0);
}
}