diff --git a/documentation/docs/tutorial.md b/documentation/docs/tutorial.md index 8669599e..c9741016 100644 --- a/documentation/docs/tutorial.md +++ b/documentation/docs/tutorial.md @@ -127,13 +127,14 @@ Define an async Rust function that runs forever, sending numbers to Dart every s ```rust title="native/hub/src/sample_functions.rs" ... use crate::messages; +use std::time::Duration; ... pub async fn stream_amazing_number() { use messages::tutorial_resource::*; let mut current_number: i32 = 1; loop { - tokio::time::sleep(std::time::Duration::from_secs(1)).await; + tokio::time::sleep(Duration::from_secs(1)).await; MyAmazingNumber { current_number }.send_signal_to_dart(); // GENERATED current_number += 1; } diff --git a/flutter_ffi_plugin/example/native/hub/src/sample_functions.rs b/flutter_ffi_plugin/example/native/hub/src/sample_functions.rs index 2205bb4b..981fbc49 100755 --- a/flutter_ffi_plugin/example/native/hub/src/sample_functions.rs +++ b/flutter_ffi_plugin/example/native/hub/src/sample_functions.rs @@ -3,6 +3,7 @@ use crate::messages; use crate::tokio; use rinf::debug_print; +use std::time::Duration; use tokio::sync::Mutex; // Using the `cfg` macro enables conditional statement. @@ -57,7 +58,7 @@ pub async fn stream_fractal() { tokio::spawn(async move { loop { // Wait for 40 milliseconds on each frame - tokio::time::sleep(std::time::Duration::from_millis(40)).await; + tokio::time::sleep(Duration::from_millis(40)).await; if sender.capacity() == 0 { continue; } @@ -120,7 +121,7 @@ pub async fn run_debug_tests() { return; } - tokio::time::sleep(std::time::Duration::from_secs(1)).await; + tokio::time::sleep(Duration::from_secs(1)).await; debug_print!("Starting debug tests."); // Get the current time. @@ -138,15 +139,15 @@ pub async fn run_debug_tests() { // Test `tokio::join!` for futures. let join_first = async { - tokio::time::sleep(std::time::Duration::from_secs(1)).await; + tokio::time::sleep(Duration::from_secs(1)).await; debug_print!("First future finished."); }; let join_second = async { - tokio::time::sleep(std::time::Duration::from_secs(2)).await; + tokio::time::sleep(Duration::from_secs(2)).await; debug_print!("Second future finished."); }; let join_third = async { - tokio::time::sleep(std::time::Duration::from_secs(3)).await; + tokio::time::sleep(Duration::from_secs(3)).await; debug_print!("Third future finished."); }; tokio::join!(join_first, join_second, join_third); diff --git a/rust_crate/src/macros.rs b/rust_crate/src/macros.rs index 8dc6097a..cdc5c8fd 100644 --- a/rust_crate/src/macros.rs +++ b/rust_crate/src/macros.rs @@ -32,9 +32,9 @@ macro_rules! write_interface { binary_pointer: *const u8, binary_size: usize, ) { - let message_bytes = - unsafe { std::slice::from_raw_parts(message_pointer, message_size) }; - let binary = unsafe { std::slice::from_raw_parts(binary_pointer, binary_size) }; + use std::slice::from_raw_parts; + let message_bytes = unsafe { from_raw_parts(message_pointer, message_size) }; + let binary = unsafe { from_raw_parts(binary_pointer, binary_size) }; messages::generated::handle_dart_signal(message_id, message_bytes, binary); }