16 releases

Uses new Rust 2024

0.1.16 Sep 20, 2025
0.1.15 Aug 17, 2024
0.1.14 Jun 13, 2024
0.1.11 Jan 8, 2024
0.1.0 Sep 11, 2023

#8 in #error-logging

Download history 165/week @ 2026-03-09 239/week @ 2026-03-16 164/week @ 2026-03-23 148/week @ 2026-03-30 216/week @ 2026-04-06 356/week @ 2026-04-13 161/week @ 2026-04-20 149/week @ 2026-04-27 115/week @ 2026-05-04 160/week @ 2026-05-11 231/week @ 2026-05-18 142/week @ 2026-05-25 186/week @ 2026-06-01

761 downloads per month
Used in 64 crates (42 directly)

MulanPSL-2.0

5KB
61 lines

xerr

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() {
    log_init::init();
    let result = size("not exist");
    assert_eq!(result, 0);
  }
}

About

This project is an open-source component of i18n.site ⋅ Internationalization Solution.

关于

本项目为 i18n.site ⋅ 国际化解决方案 的开源组件。

Dependencies

~190KB