Skip to content

Commit 845258f

Browse files
committed
Prefer core::time::Duration over std::time::Duration
1 parent adbb53b commit 845258f

File tree

14 files changed

+36
-36
lines changed

14 files changed

+36
-36
lines changed

benches/benches/bevy_picking/ray_mesh_intersection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use core::hint::black_box;
2-
use std::time::Duration;
2+
use core::time::Duration;
33

44
use benches::bench;
55
use bevy_math::{Dir3, Mat4, Ray3d, Vec3};

crates/bevy_internal/src/default_plugins.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ plugin_group! {
135135
/// or remove the loop using [`run_once`](crate::app::ScheduleRunnerPlugin::run_once).
136136
/// # Example:
137137
/// ```rust, no_run
138-
/// # use std::time::Duration;
138+
/// # use core::time::Duration;
139139
/// # use bevy_app::{App, PluginGroup, ScheduleRunnerPlugin};
140140
/// # use bevy_internal::MinimalPlugins;
141141
/// App::new().add_plugins(MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(

crates/bevy_time/src/stopwatch.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use core::time::Duration;
99
///
1010
/// ```
1111
/// # use bevy_time::*;
12-
/// use std::time::Duration;
12+
/// use core::time::Duration;
1313
/// let mut stopwatch = Stopwatch::new();
1414
/// assert_eq!(stopwatch.elapsed_secs(), 0.0);
1515
///
@@ -52,7 +52,7 @@ impl Stopwatch {
5252
/// # Examples
5353
/// ```
5454
/// # use bevy_time::*;
55-
/// use std::time::Duration;
55+
/// use core::time::Duration;
5656
/// let mut stopwatch = Stopwatch::new();
5757
/// stopwatch.tick(Duration::from_secs(1));
5858
/// assert_eq!(stopwatch.elapsed(), Duration::from_secs(1));
@@ -73,7 +73,7 @@ impl Stopwatch {
7373
/// # Examples
7474
/// ```
7575
/// # use bevy_time::*;
76-
/// use std::time::Duration;
76+
/// use core::time::Duration;
7777
/// let mut stopwatch = Stopwatch::new();
7878
/// stopwatch.tick(Duration::from_secs(1));
7979
/// assert_eq!(stopwatch.elapsed_secs(), 1.0);
@@ -105,7 +105,7 @@ impl Stopwatch {
105105
/// # Examples
106106
/// ```
107107
/// # use bevy_time::*;
108-
/// use std::time::Duration;
108+
/// use core::time::Duration;
109109
/// let mut stopwatch = Stopwatch::new();
110110
/// stopwatch.set_elapsed(Duration::from_secs_f32(1.0));
111111
/// assert_eq!(stopwatch.elapsed_secs(), 1.0);
@@ -122,7 +122,7 @@ impl Stopwatch {
122122
/// # Examples
123123
/// ```
124124
/// # use bevy_time::*;
125-
/// use std::time::Duration;
125+
/// use core::time::Duration;
126126
/// let mut stopwatch = Stopwatch::new();
127127
/// stopwatch.tick(Duration::from_secs_f32(1.5));
128128
/// assert_eq!(stopwatch.elapsed_secs(), 1.5);
@@ -140,7 +140,7 @@ impl Stopwatch {
140140
/// # Examples
141141
/// ```
142142
/// # use bevy_time::*;
143-
/// use std::time::Duration;
143+
/// use core::time::Duration;
144144
/// let mut stopwatch = Stopwatch::new();
145145
/// stopwatch.pause();
146146
/// stopwatch.tick(Duration::from_secs_f32(1.5));
@@ -157,7 +157,7 @@ impl Stopwatch {
157157
/// # Examples
158158
/// ```
159159
/// # use bevy_time::*;
160-
/// use std::time::Duration;
160+
/// use core::time::Duration;
161161
/// let mut stopwatch = Stopwatch::new();
162162
/// stopwatch.pause();
163163
/// stopwatch.tick(Duration::from_secs_f32(1.0));
@@ -193,7 +193,7 @@ impl Stopwatch {
193193
/// # Examples
194194
/// ```
195195
/// # use bevy_time::*;
196-
/// use std::time::Duration;
196+
/// use core::time::Duration;
197197
/// let mut stopwatch = Stopwatch::new();
198198
/// stopwatch.tick(Duration::from_secs_f32(1.5));
199199
/// stopwatch.reset();

crates/bevy_time/src/timer.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl Timer {
5757
/// # Examples
5858
/// ```
5959
/// # use bevy_time::*;
60-
/// use std::time::Duration;
60+
/// use core::time::Duration;
6161
///
6262
/// let mut timer_once = Timer::from_seconds(1.0, TimerMode::Once);
6363
/// timer_once.tick(Duration::from_secs_f32(1.5));
@@ -83,7 +83,7 @@ impl Timer {
8383
/// # Examples
8484
/// ```
8585
/// # use bevy_time::*;
86-
/// use std::time::Duration;
86+
/// use core::time::Duration;
8787
/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
8888
/// timer.tick(Duration::from_secs_f32(1.5));
8989
/// assert!(timer.just_finished());
@@ -103,7 +103,7 @@ impl Timer {
103103
/// # Examples
104104
/// ```
105105
/// # use bevy_time::*;
106-
/// use std::time::Duration;
106+
/// use core::time::Duration;
107107
/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
108108
/// timer.tick(Duration::from_secs_f32(0.5));
109109
/// assert_eq!(timer.elapsed(), Duration::from_secs_f32(0.5));
@@ -134,7 +134,7 @@ impl Timer {
134134
/// #
135135
/// ```
136136
/// # use bevy_time::*;
137-
/// use std::time::Duration;
137+
/// use core::time::Duration;
138138
/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
139139
/// timer.set_elapsed(Duration::from_secs(2));
140140
/// assert_eq!(timer.elapsed(), Duration::from_secs(2));
@@ -151,7 +151,7 @@ impl Timer {
151151
/// # Examples
152152
/// ```
153153
/// # use bevy_time::*;
154-
/// use std::time::Duration;
154+
/// use core::time::Duration;
155155
/// let timer = Timer::new(Duration::from_secs(1), TimerMode::Once);
156156
/// assert_eq!(timer.duration(), Duration::from_secs(1));
157157
/// ```
@@ -165,7 +165,7 @@ impl Timer {
165165
/// # Examples
166166
/// ```
167167
/// # use bevy_time::*;
168-
/// use std::time::Duration;
168+
/// use core::time::Duration;
169169
/// let mut timer = Timer::from_seconds(1.5, TimerMode::Once);
170170
/// timer.set_duration(Duration::from_secs(1));
171171
/// assert_eq!(timer.duration(), Duration::from_secs(1));
@@ -217,7 +217,7 @@ impl Timer {
217217
/// # Examples
218218
/// ```
219219
/// # use bevy_time::*;
220-
/// use std::time::Duration;
220+
/// use core::time::Duration;
221221
/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
222222
/// let mut repeating = Timer::from_seconds(1.0, TimerMode::Repeating);
223223
/// timer.tick(Duration::from_secs_f32(1.5));
@@ -273,7 +273,7 @@ impl Timer {
273273
/// # Examples
274274
/// ```
275275
/// # use bevy_time::*;
276-
/// use std::time::Duration;
276+
/// use core::time::Duration;
277277
/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
278278
/// timer.pause();
279279
/// timer.tick(Duration::from_secs_f32(0.5));
@@ -291,7 +291,7 @@ impl Timer {
291291
/// # Examples
292292
/// ```
293293
/// # use bevy_time::*;
294-
/// use std::time::Duration;
294+
/// use core::time::Duration;
295295
/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
296296
/// timer.pause();
297297
/// timer.tick(Duration::from_secs_f32(0.5));
@@ -330,7 +330,7 @@ impl Timer {
330330
/// Examples
331331
/// ```
332332
/// # use bevy_time::*;
333-
/// use std::time::Duration;
333+
/// use core::time::Duration;
334334
/// let mut timer = Timer::from_seconds(1.0, TimerMode::Once);
335335
/// timer.tick(Duration::from_secs_f32(1.5));
336336
/// timer.reset();
@@ -349,7 +349,7 @@ impl Timer {
349349
/// # Examples
350350
/// ```
351351
/// # use bevy_time::*;
352-
/// use std::time::Duration;
352+
/// use core::time::Duration;
353353
/// let mut timer = Timer::from_seconds(2.0, TimerMode::Once);
354354
/// timer.tick(Duration::from_secs_f32(0.5));
355355
/// assert_eq!(timer.fraction(), 0.25);
@@ -368,7 +368,7 @@ impl Timer {
368368
/// # Examples
369369
/// ```
370370
/// # use bevy_time::*;
371-
/// use std::time::Duration;
371+
/// use core::time::Duration;
372372
/// let mut timer = Timer::from_seconds(2.0, TimerMode::Once);
373373
/// timer.tick(Duration::from_secs_f32(0.5));
374374
/// assert_eq!(timer.fraction_remaining(), 0.75);
@@ -384,7 +384,7 @@ impl Timer {
384384
/// ```
385385
/// # use bevy_time::*;
386386
/// use std::cmp::Ordering;
387-
/// use std::time::Duration;
387+
/// use core::time::Duration;
388388
/// let mut timer = Timer::from_seconds(2.0, TimerMode::Once);
389389
/// timer.tick(Duration::from_secs_f32(0.5));
390390
/// let result = timer.remaining_secs().total_cmp(&1.5);
@@ -400,7 +400,7 @@ impl Timer {
400400
/// # Examples
401401
/// ```
402402
/// # use bevy_time::*;
403-
/// use std::time::Duration;
403+
/// use core::time::Duration;
404404
/// let mut timer = Timer::from_seconds(2.0, TimerMode::Once);
405405
/// timer.tick(Duration::from_secs_f32(0.5));
406406
/// assert_eq!(timer.remaining(), Duration::from_secs_f32(1.5));
@@ -419,7 +419,7 @@ impl Timer {
419419
/// # Examples
420420
/// ```
421421
/// # use bevy_time::*;
422-
/// use std::time::Duration;
422+
/// use core::time::Duration;
423423
/// let mut timer = Timer::from_seconds(1.0, TimerMode::Repeating);
424424
/// timer.tick(Duration::from_secs_f32(6.0));
425425
/// assert_eq!(timer.times_finished_this_tick(), 6);

examples/2d/sprite_animation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! See `sprite_sheet.rs` for an example where the sprite animation loops indefinitely.
44
5-
use std::time::Duration;
5+
use core::time::Duration;
66

77
use bevy::{input::common_conditions::input_just_pressed, prelude::*};
88

examples/async_tasks/async_compute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use bevy::{
66
prelude::*,
77
tasks::{block_on, futures_lite::future, AsyncComputeTaskPool, Task},
88
};
9+
use core::time::Duration;
910
use rand::Rng;
10-
use std::time::Duration;
1111

1212
fn main() {
1313
App::new()

examples/audio/pitch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This example illustrates how to play a single-frequency sound (aka a pitch)
22
33
use bevy::prelude::*;
4-
use std::time::Duration;
4+
use core::time::Duration;
55

66
fn main() {
77
App::new()

examples/diagnostics/enabling_disabling_diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Shows how to disable/re-enable a Diagnostic during runtime
22
3-
use std::time::Duration;
3+
use core::time::Duration;
44

55
use bevy::{
66
diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},

examples/ecs/observer_propagation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Demonstrates how to propagate events through the hierarchy with observers.
22
3-
use std::time::Duration;
3+
use core::time::Duration;
44

55
use bevy::{log::LogPlugin, prelude::*, time::common_conditions::on_timer};
66
use rand::{seq::IteratorRandom, thread_rng, Rng};

examples/stress_tests/many_animated_sprites.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! This example sets up many animated sprites in different sizes, rotations, and scales in the world.
44
//! It also moves the camera over them to see how well frustum culling works.
55
6-
use std::time::Duration;
6+
use core::time::Duration;
77

88
use bevy::{
99
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},

examples/time/virtual_time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Shows how `Time<Virtual>` can be used to pause, resume, slow down
22
//! and speed up a game.
33
4-
use std::time::Duration;
4+
use core::time::Duration;
55

66
use bevy::{
77
color::palettes::css::*, input::common_conditions::input_just_pressed, prelude::*,

examples/ui/directional_navigation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//!
66
//! In this example, we will set up a simple UI with a grid of buttons that can be navigated using the arrow keys or gamepad input.
77
8-
use std::time::Duration;
8+
use core::time::Duration;
99

1010
use bevy::{
1111
input_focus::{

examples/window/custom_cursor_image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Illustrates how to use a custom cursor image with a texture atlas and
22
//! animation.
33
4-
use std::time::Duration;
4+
use core::time::Duration;
55

66
use bevy::{
77
prelude::*,

tests/window/change_window_mode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ fn toggle_window_mode(mut qry_window: Query<&mut Window>) {
4848
window.mode = match window.mode {
4949
WindowMode::Windowed => {
5050
// it takes a while for the window to change from `Windowed` to `Fullscreen` and back
51-
std::thread::sleep(std::time::Duration::from_secs(4));
51+
std::thread::sleep(core::time::Duration::from_secs(4));
5252
WindowMode::Fullscreen(
5353
MonitorSelection::Entity(entity),
5454
VideoModeSelection::Current,
5555
)
5656
}
5757
_ => {
58-
std::thread::sleep(std::time::Duration::from_secs(4));
58+
std::thread::sleep(core::time::Duration::from_secs(4));
5959
WindowMode::Windowed
6060
}
6161
};

0 commit comments

Comments
 (0)