Skip to content

docs: fix angle unit in quick start example (#1837) - #1839

Merged
dhardy merged 1 commit into
rust-random:masterfrom
CyberneticX-Tech:docs/fix-angle-example-radians
Sep 8, 2026
Merged

docs: fix angle unit in quick start example (#1837)#1839
dhardy merged 1 commit into
rust-random:masterfrom
CyberneticX-Tech:docs/fix-angle-example-radians

Conversation

@CyberneticX-Tech

Copy link
Copy Markdown
Contributor

Summary

Fixes the unit mentioned in the quick start documentation example in src/lib.rs.

Motivation

Resolves #1837. The ranged sampling example samples a value from -PI..PI. A range of [-π, π] corresponds to radians rather than degrees, so printing "degrees" was misleading for readers running or copying the example.

Details

Updated src/lib.rs:

// Ranged sampling:
use std::f32::consts::PI;
println!("Angle: {} radians", rand::random_range(-PI..PI));

Tested with cargo test --doc and cargo clippy --all-targets (all clean).

The ranged sampling example in src/lib.rs samples an angle from
-PI..PI, which corresponds to radians rather than degrees.

Fixes rust-random#1837
@dhardy
dhardy merged commit c994eb1 into rust-random:master Sep 8, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CHANGE: Increase correctness of angle example in the documentation

2 participants