@@ -64,19 +64,6 @@ pub(crate) fn do_write<X>(
6464 write ! ( f, "{}" , suffix)
6565}
6666
67- /// Shorthand for using [After](crate::Offset::After) together with [delay].
68- ///
69- /// ```
70- /// use std::time::Duration;
71- /// use reactor_rt::{after, Offset::After};
72- ///
73- /// assert_eq!(after!(10 ns), After(Duration::from_nanos(10)));
74- /// assert_eq!(after!(2 min), After(Duration::from_secs(120)));
75- /// ```
76- #[ macro_export]
77- macro_rules! after {
78- ( $amount: tt $unit: tt) => { $crate:: Offset :: After ( $crate:: delay!( $amount $unit) ) }
79- }
8067
8168/// Creates a [Duration] value using the same syntax as in LF.
8269///
@@ -133,6 +120,45 @@ macro_rules! delay {
133120 ( $amount: tt $i: ident) => { compile_error!( concat!( "Unknown time unit `" , stringify!( $i) , "`" ) ) } ;
134121}
135122
123+ /// Shorthand for using [After](crate::Offset::After) together with [delay].
124+ ///
125+ /// ```
126+ /// use std::time::Duration;
127+ /// use reactor_rt::{after, Offset::After};
128+ ///
129+ /// assert_eq!(after!(10 ns), After(Duration::from_nanos(10)));
130+ /// assert_eq!(after!(2 min), After(Duration::from_secs(120)));
131+ /// ```
132+ #[ macro_export]
133+ macro_rules! after {
134+ ( $amount: tt $unit: tt) => { $crate:: Offset :: After ( $crate:: delay!( $amount $unit) ) }
135+ }
136+
137+ /// Convenient macro to [create a tag](crate::EventTag).
138+ /// This is just a shorthand for using the constructor together
139+ /// with the syntax of [delay].
140+ ///
141+ /// ```no_run
142+ /// use reactor_rt::{tag, delay};
143+ ///
144+ /// tag!(T0 + 20 ms);
145+ /// tag!(T0 + 60 ms);
146+ /// tag!(T0); // the origin tag
147+ /// // with a microstep:
148+ /// tag!(T0, 1);
149+ /// tag!(T0 + 3 sec, 1);
150+ /// ```
151+ #[ macro_export]
152+ macro_rules! tag {
153+ ( T0 ) => { $crate:: EventTag :: ORIGIN } ;
154+ ( T0 , $microstep: expr) => { tag!( T0 + 0 sec, $microstep) } ;
155+ ( T0 + $amount: tt $unit: ident) => { tag!( T0 + $amount $unit, 0 ) } ;
156+ ( T0 + $amount: tt $unit: ident, $microstep: expr) => {
157+ $crate:: EventTag :: offset( $crate:: delay!( $amount $unit) , $microstep)
158+ } ;
159+ }
160+
161+
136162/// Convenient macro to assert equality of the current tag.
137163/// This is just shorthand for using `assert_eq!` with the
138164/// syntax of [tag].
@@ -164,30 +190,6 @@ macro_rules! assert_tag_is {
164190 } ;
165191}
166192
167- /// Convenient macro to [create a tag](crate::EventTag).
168- /// This is just a shorthand for using the constructor together
169- /// with the syntax of [delay].
170- ///
171- /// ```no_run
172- /// use reactor_rt::{tag, delay};
173- ///
174- /// tag!(T0 + 20 ms);
175- /// tag!(T0 + 60 ms);
176- /// tag!(T0); // the origin tag
177- /// // with a microstep:
178- /// tag!(T0, 1);
179- /// tag!(T0 + 3 sec, 1);
180- /// ```
181- #[ macro_export]
182- macro_rules! tag {
183- ( T0 ) => { $crate:: EventTag :: ORIGIN } ;
184- ( T0 , $microstep: expr) => { tag!( T0 + 0 sec, $microstep) } ;
185- ( T0 + $amount: tt $unit: ident) => { tag!( T0 + $amount $unit, 0 ) } ;
186- ( T0 + $amount: tt $unit: ident, $microstep: expr) => {
187- $crate:: EventTag :: offset( $crate:: delay!( $amount $unit) , $microstep)
188- } ;
189- }
190-
191193/// A unit of time, used in LF.
192194#[ derive( Debug ) ]
193195pub enum TimeUnit {
0 commit comments