【Rust日报】一本新书:黑帽Rust

2024 Rust中国大会大会将于 9 月 07 日 - 08 日在上海举办。精彩议题逐步放出中,欢迎大家面对面交流。

2024 Rust中国大会报名链接暨第一批精彩演讲主题介绍

2024 Rust中国大会第二批精彩演讲主题列表

2024 Rust中国大会第三批精彩演讲主题列表


马尔科夫文本生成算法
let training_path = "data";

// Gets the paths of evey file and directory in the training_path.
let tpaths = fs::read_dir(training_path)
 .unwrap_or_else(|_| panic!("Can't read files from: {}", training_path));

// Only the files remain
let files = tpaths
 .filter_map(|f| f.ok())
 .filter(|f| match f.file_type() {
  Err(_) => false,
  Ok(f) => f.is_file(),
 });

// Reads every file into a string
let contents = files.filter_map(|f| read_to_string(f.path()).ok());

// Creating the Markov Chain
let markov_chain = contents.fold(
 MarkovChain::with_capacity(2, 8_000_000, Regex::new(WORD_REGEX).unwrap()),
 |mut a, s| {
  a.add_text(&s);
  a
 },
);

// Number of tokens
println!("{}", markov_chain.len());

// Generation
for _ in 0..10 {
 println!("{}", markov_chain.generate_start("among the       ", 25).unwrap());
}

https://github.com/Brogolem35/markov_str

Runnables CLI - 在工作区下运行可执行文件的TUI工具

在Rust的工作区中,常常有多个可执行文件,比如很多examples什么的。这时,这个工作有助于减少打字量。

https://crates.io/crates/runnables-cli

一本新书:黑帽Rust

用Rust实现软件攻防。

https://kerkour.com/black-hat-rust

trippy - 网络路由工具

已超3k+ stars.

https://github.com/fujiapple852/trippy

--

From 日报小组 Mike

社区学习交流平台订阅:

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


请使用浏览器的分享功能分享到微信等