chore: move macros around
This commit is contained in:
1 parent
0e12915dc8
commit
e51b47d1fb
2 files changed
+25
-25
No files matched your search
@@ -102,3 +102,26 @@ pub(crate) mod unsafe_utils {
|
|||||||
std::mem::transmute(node)
|
std::mem::transmute(node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
/// A helper macro for using hooks in async environements.
|
||||||
|
///
|
||||||
|
/// # Usage
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// let (data) = use_ref(&cx, || {});
|
||||||
|
///
|
||||||
|
/// let handle_thing = move |_| {
|
||||||
|
/// to_owned![data]
|
||||||
|
/// cx.spawn(async move {
|
||||||
|
/// // do stuff
|
||||||
|
/// });
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
macro_rules! to_owned {
|
||||||
|
($($es:ident),+) => {$(
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
let mut $es = $es.to_owned();
|
||||||
|
)*}
|
||||||
|
}
|
||||||
@@ -16,28 +16,5 @@ pub use usecoroutine::*;
|
|||||||
mod usefuture;
|
mod usefuture;
|
||||||
pub use usefuture::*;
|
pub use usefuture::*;
|
||||||
|
|
||||||
mod useeffect;
|
// mod usesuspense;
|
||||||
pub use useeffect::*;
|
// pub use usesuspense::*;
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
/// A helper macro for using hooks in async environements.
|
|
||||||
///
|
|
||||||
/// # Usage
|
|
||||||
///
|
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// let (data) = use_ref(&cx, || {});
|
|
||||||
///
|
|
||||||
/// let handle_thing = move |_| {
|
|
||||||
/// to_owned![data]
|
|
||||||
/// cx.spawn(async move {
|
|
||||||
/// // do stuff
|
|
||||||
/// });
|
|
||||||
/// }
|
|
||||||
/// ```
|
|
||||||
macro_rules! to_owned {
|
|
||||||
($($es:ident),+) => {$(
|
|
||||||
#[allow(unused_mut)]
|
|
||||||
let mut $es = $es.to_owned();
|
|
||||||
)*}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user