kgv / rust_book_ru

The Rust Programming Language (на русском) (основной репозиторий теперь здесь: https://github.com/ruRust/rust_book_ru)
211 stars 22 forks source link

thread::sleep_ms(1000) #350

Open Gresand opened 10 months ago

Gresand commented 10 months ago

Hi all! I'm a newbie, don't judge too harshly. On page 44 and below, the thread::sleep_ms(1000) method is used, which throws an error.

thread::sleep_ms(1000);

use of deprecated function `std::thread::sleep_ms`: replaced by `std::thread::sleep`

As written in the footnote, we need to use use::time, I don’t know to what extent this is true.

use std::time;

let ten_millis = time::Duration::from_millis(1000);
thread::sleep(ten_millis);

sleep_ms