@@ -64,20 +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- }
80-
8167/// Creates a [Duration] value using the same syntax as in LF.
8268///
8369/// ```
@@ -133,6 +119,44 @@ macro_rules! delay {
133119 ( $amount: tt $i: ident) => { compile_error!( concat!( "Unknown time unit `" , stringify!( $i) , "`" ) ) } ;
134120}
135121
122+ /// Shorthand for using [After](crate::Offset::After) together with [delay].
123+ ///
124+ /// ```
125+ /// use std::time::Duration;
126+ /// use reactor_rt::{after, Offset::After};
127+ ///
128+ /// assert_eq!(after!(10 ns), After(Duration::from_nanos(10)));
129+ /// assert_eq!(after!(2 min), After(Duration::from_secs(120)));
130+ /// ```
131+ #[ macro_export]
132+ macro_rules! after {
133+ ( $amount: tt $unit: tt) => { $crate:: Offset :: After ( $crate:: delay!( $amount $unit) ) }
134+ }
135+
136+ /// Convenient macro to [create a tag](crate::EventTag).
137+ /// This is just a shorthand for using the constructor together
138+ /// with the syntax of [delay].
139+ ///
140+ /// ```no_run
141+ /// use reactor_rt::{tag, delay};
142+ ///
143+ /// tag!(T0 + 20 ms);
144+ /// tag!(T0 + 60 ms);
145+ /// tag!(T0); // the origin tag
146+ /// // with a microstep:
147+ /// tag!(T0, 1);
148+ /// tag!(T0 + 3 sec, 1);
149+ /// ```
150+ #[ macro_export]
151+ macro_rules! tag {
152+ ( T0 ) => { $crate:: EventTag :: ORIGIN } ;
153+ ( T0 , $microstep: expr) => { tag!( T0 + 0 sec, $microstep) } ;
154+ ( T0 + $amount: tt $unit: ident) => { tag!( T0 + $amount $unit, 0 ) } ;
155+ ( T0 + $amount: tt $unit: ident, $microstep: expr) => {
156+ $crate:: EventTag :: offset( $crate:: delay!( $amount $unit) , $microstep)
157+ } ;
158+ }
159+
136160/// Convenient macro to assert equality of the current tag.
137161/// This is just shorthand for using `assert_eq!` with the
138162/// syntax of [tag].
@@ -164,30 +188,6 @@ macro_rules! assert_tag_is {
164188 } ;
165189}
166190
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-
191191/// A unit of time, used in LF.
192192#[ derive( Debug ) ]
193193pub enum TimeUnit {
0 commit comments