mirror of
https://github.com/Noratrieb/simple-std.git
synced 2026-01-16 09:25:05 +01:00
fixed crate doc example
This commit is contained in:
parent
edae442575
commit
46edba9b57
1 changed files with 19 additions and 16 deletions
35
src/lib.rs
35
src/lib.rs
|
|
@ -2,24 +2,27 @@
|
||||||
//! # Example: guessing game
|
//! # Example: guessing game
|
||||||
//! ```
|
//! ```
|
||||||
//! use std::cmp::Ordering;
|
//! use std::cmp::Ordering;
|
||||||
// use simple_std::{prompt, random_int_range};
|
//! use simple_std::{prompt, random_int_range};
|
||||||
//
|
//!
|
||||||
// fn main() {
|
//! let number = random_int_range(0..100);
|
||||||
// let number = random_int_range(0..100);
|
//! loop {
|
||||||
// loop {
|
//!# // hack the input function for this to work in the doc test
|
||||||
// let input = prompt("Guess: ").parse::<i32>().expect("not a number");
|
//!# fn prompt(_str: &str) -> String {
|
||||||
// match input.cmp(&number) {
|
//!# random_int_range(0..100).to_string()
|
||||||
// Ordering::Less => println!("Too Small"),
|
//!# }
|
||||||
// Ordering::Greater => println!("Too Big"),
|
//! let input = prompt("guess: ").parse::<i32>().expect("not a number");
|
||||||
// Ordering::Equal => {
|
//! match input.cmp(&number) {
|
||||||
// println!("You win!");
|
//! Ordering::Less => println!("Too Small"),
|
||||||
// break;
|
//! Ordering::Greater => println!("Too Big"),
|
||||||
// }
|
//! Ordering::Equal => {
|
||||||
// }
|
//! println!("You win!");
|
||||||
// }
|
//! break;
|
||||||
// }
|
//! }
|
||||||
|
//! }
|
||||||
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
|
||||||
pub use io::{input, prompt};
|
pub use io::{input, prompt};
|
||||||
pub use random::{random_float, random_int_range};
|
pub use random::{random_float, random_int_range};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue