Rust 程序设计语言 简体中文版 1.85.0
std::io; use rand::Rng; fn main() { println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1..=100); println!("The secret number is: {secret_number}"); println!("Please trait,它定义了随机数生成器应实现的 方法,想使用这些方法的话,此 trait 必须在作用域中。第十章会详细介绍 trait。 接下来,我们在中间还新增加了两行。第一行调用了 rand::thread_rng 函数提供实际使用的 随机数生成器:它位于当前执行线程的本地环境中,并从操作系统获取 seed。接着调用随机 数生成器的 gen_range 方法。这个方法由 use rand::Rng guessed: 60 Too big! Please input your guess. 59 You guessed: 59 You win! Please input your guess. quit thread 'main' panicked at src/main.rs:28:47: Please type a number!: ParseIntError { kind: InvalidDigit }0 码力 | 562 页 | 3.23 MB | 9 天前3Tornado 6.5 Documentation
different from most Python web frameworks. It is not based on WSGI, and it is typically run with only one thread per process. See the User’s guide for more on Tornado’s approach to asynchronous programming. While interfaces (such as tornado.web) directly instead of using WSGI. In general, Tornado code is not thread-safe. The only method in Tornado that is safe to call from other threads is IOLoop.add_callback. You can also use IOLoop.run_in_executor to asynchronously run a blocking function on another thread, but note that the function passed to run_in_executor should avoid referencing any Tornado objects.0 码力 | 272 页 | 1.12 MB | 2 月前3Tornado 6.5 Documentation
not based on WSGI [https://wsgi.readthedocs.io/en/latest/], and it is typically run with only one thread per process. See the User’s guide for more on Tornado’s approach to asynchronous programming. While interfaces (such as tornado.web) directly instead of using WSGI. In general, Tornado code is not thread-safe. The only method in Tornado that is safe to call from other threads is IOLoop.add_callback. You can also use IOLoop.run_in_executor to asynchronously run a blocking function on another thread, but note that the function passed to run_in_executor should avoid referencing any Tornado objects.0 码力 | 437 页 | 405.14 KB | 2 月前3
共 3 条
- 1