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

【Rust日报】 2019-07-28:Rust Unsafe:把它们看作公理和定理

来源:互联网 收集:自由互联 发布时间:2022-06-30
关于 Web 前端开发框架 Seed 的一些资料 Seed(https://seed-rs.org/) 也是一个前端 Web 开发框架。这是用 Seed 写的一个前端网站(https://seed-rs-realworld.netlify.com/),这里是一些相关的资源(https

关于 Web 前端开发框架 Seed 的一些资料

Seed(https://seed-rs.org/) 也是一个前端 Web 开发框架。这是用 Seed 写的一个前端网站(https://seed-rs-realworld.netlify.com/),这里是一些相关的资源(https://github.com/MartinKavik/awesome-seed-rs)。

Repo

已经用上 wasm 技术的一些网站

这里列举一些,不完整,会不断增加

  • ​​https://apps.karthikkaranth.me/spherro/​​
  • ​​https://lukaslueg.github.io/macro_railroad_wasm_demo/​​
  • https://sandspiel.club/ 落沙游戏

Rust Unsafe:把它们看作公理和定理

这篇文章https://iandouglasscott.com/2019/07/26/rust-safe-and-unsafe-as-theorems-and-axioms/ 作者从另一个视角来探讨了 Rust 中的 unsafe 的概念,他建议,可以将 Rust Unsafe 类比看作数学上的公理和定理。基于这个观点,做出了详细的剖析。详情请看原文。

SCalc - 保证不会溢出的计算库

很简单的思路,如果发现溢出了,结果就置为 1。一定程度上,可保证计算安全,不会由于偶然的原因,导致系统崩溃。

比如:

use scalc::SCell;

fn main() {
let a = SCell::<i32>::new(12) * SCell::<i32>::new(3);
assert_eq!(*a.get_data(), 36);

// `error_tag` will be `true` in the presence of overflow behavior(s)
let a = SCell::<i32>::new(std::i32::MAX) + SCell::<i32>::new(1);
assert_eq!(a.is_overflowed(), true);
assert_eq!(*a.get_data(), 1);
}

​​https://github.com/XCH-CEB/xch-project/tree/master/scalc​​

cargo-cache - 帮助你管理你本地的 registry 缓存

比如会给出这样一个报告。

Total: 3.81 GB
107 installed binaries: 916.89 MB
Registry: 163.43 MB
Registry index: 156.47 MB
5 crate archives: 6.96 MB
Registry: dl.cloudsmith.io 4.18 KB
Registry index: 3.21 KB
1 crate archives: 971 B
Registry: github.com 1.34 GB
Registry index: 98.51 MB
5522 crate archives: 812.62 MB
743 crate source checkouts: 426.25 MB
Registry: home 478 B
Registry index: 478 B
Registry: ship.rs 478 B
Registry index: 478 B
Git db: 1.40 GB
138 bare git repos: 1.37 GB
6 git repo checkouts: 23.53 MB

还有相关其它配套功能。使用下面命令安装:

cargo install cargo-cache

Bayes-O-Matic - 帮助你对一些问题做贝叶斯推演的一个Webapp程序(用wasm实现)

演示地址在这里:https://vberger.github.io/Bayes-O-Matic/

讲解文章在这里:https://vberger.github.io/Bayes-O-Matic/help.html

kmean-rs - 实现 K 均值聚类的小而快的库

这是一个例子:

use kmeans::*;

fn main() {
let (sample_cnt, sample_dims, k, max_iter) = (20000, 200, 4, 100);

// Generate some random data
let mut samples = vec![0.0f64;sample_cnt * sample_dims];
samples.iter_mut().for_each(|v| *v = rand::random());

// Calculate kmeans, using kmean++ as initialization-method
let kmean = KMeans::new(samples, sample_cnt, sample_dims);
let result = kmean.kmeans(k, max_iter, KMeans::init_kmeanplusplus, &mut rand::thread_rng());

println!("Centroids: {:?}", result.centroids);
println!("Cluster-Assignments: {:?}", result.assignments);
println!("Error: {}", result.distsum);
}

​​https://github.com/seijikun/kmean-rs​​

Animate code with awoo!

https://phaazon.net/blog/introducing-awoo 这篇文章,从风格上,我觉得挺诡异,没看懂,各位看观有兴趣来点评一下?



日报订阅地址:

独立日报订阅地址:

  • Telgram Channel
  • 阿里云语雀订阅
  • Steemit
  • GitHub

社区学习交流平台订阅:

  • Rust.cc 论坛: 支持 rss
  • Rust Force: 支持 rss
  • 微信公众号:Rust 语言学习交流


网友评论