-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathregularex.rs
71 lines (42 loc) · 1.18 KB
/
regularex.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use super::prelude::*;
pub mod exports {
#[ cfg ( feature = "vonuvoli_values_string" ) ]
pub use super::{
StringRegex,
};
#[ cfg ( feature = "vonuvoli_values_bytes" ) ]
pub use super::{
BytesRegex,
};
}
macro_rules! define_regex {
( $type : ident, $wrapped : ty ) => {
#[ derive ( Clone ) ] // OK
#[ cfg_attr ( feature = "vonuvoli_fmt_debug", derive ( Debug ) ) ] // OK
pub struct $type ( StdRc<$wrapped> );
impl $type {
pub fn new (regex : $wrapped) -> ($type) {
$type (StdRc::new (regex))
}
pub fn regex_ref (&self) -> (&$wrapped) {
&self.0
}
pub fn from_rc (rc : StdRc<$wrapped>) -> ($type) {
$type (rc)
}
pub fn clone_rc (rc : &StdRc<$wrapped>) -> ($type) {
$type::from_rc (StdRc::clone (rc))
}
pub fn is_self (&self, other : &$type) -> (bool) {
StdRc::ptr_eq (&self.0, &other.0)
}
pub fn internal_rc_clone (&self) -> (StdRc<$wrapped>) {
StdRc::clone (&self.0)
}
}
};
}
#[ cfg ( feature = "vonuvoli_values_string" ) ]
define_regex! (StringRegex, regex::Regex);
#[ cfg ( feature = "vonuvoli_values_bytes" ) ]
define_regex! (BytesRegex, regex::bytes::Regex);