@@ -23,6 +23,15 @@ struct Tag {
2323 length : usize ,
2424}
2525
26+ impl Tag {
27+ const fn new ( value : & str ) -> Self {
28+ Self {
29+ data : value. as_ptr ( ) ,
30+ length : value. len ( ) ,
31+ }
32+ }
33+ }
34+
2635unsafe impl Send for Tag { }
2736unsafe impl Sync for Tag { }
2837
@@ -86,6 +95,12 @@ impl From<&str> for Tag {
8695#[ repr( C ) ]
8796pub struct MonitorTag ( Tag ) ;
8897
98+ impl MonitorTag {
99+ pub const fn new ( value : & str ) -> Self {
100+ MonitorTag ( Tag :: new ( value) )
101+ }
102+ }
103+
89104impl fmt:: Debug for MonitorTag {
90105 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
91106 // SAFETY: the underlying data was created from a valid `&str`.
@@ -121,6 +136,12 @@ impl From<&str> for MonitorTag {
121136#[ repr( C ) ]
122137pub struct DeadlineTag ( Tag ) ;
123138
139+ impl DeadlineTag {
140+ pub const fn new ( value : & str ) -> Self {
141+ DeadlineTag ( Tag :: new ( value) )
142+ }
143+ }
144+
124145impl fmt:: Debug for DeadlineTag {
125146 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
126147 // SAFETY: the underlying data was created from a valid `&str`.
@@ -230,6 +251,13 @@ mod tests {
230251 assert_eq ! ( tag_as_str, expected) ;
231252 }
232253
254+ #[ test]
255+ fn tag_new ( ) {
256+ const EXAMPLE_STR : & str = "EXAMPLE" ;
257+ const TAG : Tag = Tag :: new ( EXAMPLE_STR ) ;
258+ compare_tag ( TAG , EXAMPLE_STR ) ;
259+ }
260+
233261 #[ test]
234262 fn tag_debug ( ) {
235263 let example_str = "EXAMPLE" ;
@@ -312,6 +340,13 @@ mod tests {
312340 compare_tag ( tag, example_str) ;
313341 }
314342
343+ #[ test]
344+ fn monitor_tag_new ( ) {
345+ const EXAMPLE_STR : & str = "EXAMPLE" ;
346+ const TAG : MonitorTag = MonitorTag :: new ( EXAMPLE_STR ) ;
347+ compare_tag ( TAG . 0 , EXAMPLE_STR ) ;
348+ }
349+
315350 #[ test]
316351 fn monitor_tag_debug ( ) {
317352 let example_str = "EXAMPLE" ;
@@ -342,6 +377,13 @@ mod tests {
342377 compare_tag ( tag. 0 , example_str) ;
343378 }
344379
380+ #[ test]
381+ fn deadline_tag_new ( ) {
382+ const EXAMPLE_STR : & str = "EXAMPLE" ;
383+ const TAG : DeadlineTag = DeadlineTag :: new ( EXAMPLE_STR ) ;
384+ compare_tag ( TAG . 0 , EXAMPLE_STR ) ;
385+ }
386+
345387 #[ test]
346388 fn deadline_tag_debug ( ) {
347389 let example_str = "EXAMPLE" ;
0 commit comments