当前位置 : 主页 > 编程语言 > java >

【Rust日报】2020-10-19 通过 本福特定律 来学习 Rust

来源:互联网 收集:自由互联 发布时间:2022-06-22
通过​​ 本福特定律 ​​ 来学习 Rust 本福特定律,也称为本福特法则,说明一堆从实际生活得出的数据中,以1为首位数字的数的出现概率约为总数的三成,接近直觉得出之期望值1/


通过​​本福特定律​​来学习 Rust

本福特定律,也称为本福特法则,说明一堆从实际生活得出的数据中,以1为首位数字的数的出现概率约为总数的三成,接近直觉得出之期望值1/9的3倍。推广来说,越大的数,以它为首几位的数出现的概率就越低。它可用于检查各种数据是否有造假。(来自百度百科)

这篇文章通过验证​​本福特定律​​的方式来学习 Rust (入门级).

大纲如下:

  • 本福特定律 介绍
  • Installing Rust
  • Setting up the Project
  • Reading the Dataset
  • Logging
  • Parsing the Dataset
  • Comparing Results
  • Error Handling
  • Command Line Arguments
  • 总结

原文链接:https://gliderkite.github.io/posts/learn-rust-with-benford/

shared-arena: 一个线程安全的 memory pool

​​shared-arena​​ 是一个 memory pool. 当不停的申请和释放大量的相同 size 的数据时, memory pool 可以有效的减少 allocating 和 deallocating 的时间.

github地址:https://github.com/sebastiencs/shared-arena

xshell: Rust 中优雅的编写调用 bash 脚本

​​xshell​​ 是一个 Rust 库, 可以让你在 Rust 中优雅的调用和编写 bash 脚本.

跨平台, 让你专注于 shell 脚本的编写.

use xshell::{cmd, read_file};

let name = "Julia";
let output = cmd!("echo hello {name}!").read()?;
assert_eq!(output, "hello Julia!");

let err = read_file("feeling-lucky.txt").unwrap_err();
assert_eq!(
err.to_string(),
"`feeling-lucky.txt`: no such file or directory (os error 2)",
);

github地址:https://github.com/matklad/xshell

timed: 使用宏来profile你的程序

​​timed​​ 是一个新的 profiling 工具, 主要使用宏来标记需要 profile 的函数等.

具有以下特性:

  • 支持 ​​main​​
  • 支持 ​​async​​
  • 支持多种 printer, 例如 ​​println!​​​​info!​​ 或者其他自定义.
  • 支持chrome中的 tracing 展示结果.

github地址:https://github.com/y2kappa/timed

--

社区学习交流平台订阅:

  • Rustcc论坛: 支持rss
  • 微信公众号:Rust语言中文社区


【本文由:湖北阿里云代理 http://www.558idc.com/aliyun.html 复制请保留原URL】
上一篇:【大家的项目】纯 Rust 写的私有云
下一篇:没有了
网友评论