知识卡片
随机工具也受版本契约约束
rand提供随机数生成及相关接口,可复用底层平台能力。示例0.7与0.8的gen_range参数形状不同,说明同一用途工具仍有版本契约;生成器类型也不能跨不兼容版本直接混用。这里不是密码学随机源选择结论,实际安全用途仍需核验算法与目标平台。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 4. Dependencies Item 24: Re-export dependencies whose types appear in your API · 查看原书依据
rand crate—more specifically, one that uses some 0.8 version of the crate: # Cargo.toml file for a top-level binary crate. [dependencies] # The binary depends on the `rand` crate from crates.io rand = "=0.8.5" # It also depends on some other crate (`dep-lib`). dep-lib = "0.1.0" // Source code: let mut rng = rand::thread_rng(); // rand 0.8 let max: usize = rn
参考来源
- 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第4章《Item 24: Re-export dependencies whose types appear in your API》(spine8;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch04.html;u123-ch04-013)。
- 结论依据:原文在“rand crate”附近的定义、例子或代码支撑本卡核心说明:rand提供随机数生成及相关接口,可复用底层平台能力。边界按已读前提解释;示例未执行。
- 原始内容:rand crate—more specifically, one that uses some 0.8 version of the crate: # Cargo.toml file for a top-level binary crate. [dependencies] # The binary depends on the `rand` crate from crates.io rand = "=0.8.5" # It also depends on some other crate (`dep-lib`). dep-lib = "0.1.0" // Source code: let mut rng = rand::thread_rng(); // rand 0.8 let max: usize = rn