@@ -5,7 +5,7 @@ use std::str::Chars;
5
5
use std:: ops:: Range ;
6
6
7
7
#[ derive( Debug , PartialEq , Eq ) ]
8
- pub ( crate ) enum EscapeError {
8
+ pub enum EscapeError {
9
9
ZeroChars ,
10
10
MoreThanOneChar ,
11
11
@@ -35,22 +35,22 @@ pub(crate) enum EscapeError {
35
35
36
36
/// Takes a contents of a char literal (without quotes), and returns an
37
37
/// unescaped char or an error
38
- pub ( crate ) fn unescape_char ( literal_text : & str ) -> Result < char , ( usize , EscapeError ) > {
38
+ pub fn unescape_char ( literal_text : & str ) -> Result < char , ( usize , EscapeError ) > {
39
39
let mut chars = literal_text. chars ( ) ;
40
40
unescape_char_or_byte ( & mut chars, Mode :: Char )
41
41
. map_err ( |err| ( literal_text. len ( ) - chars. as_str ( ) . len ( ) , err) )
42
42
}
43
43
44
44
/// Takes a contents of a string literal (without quotes) and produces a
45
45
/// sequence of escaped characters or errors.
46
- pub ( crate ) fn unescape_str < F > ( literal_text : & str , callback : & mut F )
46
+ pub fn unescape_str < F > ( literal_text : & str , callback : & mut F )
47
47
where
48
48
F : FnMut ( Range < usize > , Result < char , EscapeError > ) ,
49
49
{
50
50
unescape_str_or_byte_str ( literal_text, Mode :: Str , callback)
51
51
}
52
52
53
- pub ( crate ) fn unescape_byte ( literal_text : & str ) -> Result < u8 , ( usize , EscapeError ) > {
53
+ pub fn unescape_byte ( literal_text : & str ) -> Result < u8 , ( usize , EscapeError ) > {
54
54
let mut chars = literal_text. chars ( ) ;
55
55
unescape_char_or_byte ( & mut chars, Mode :: Byte )
56
56
. map ( byte_from_char)
@@ -59,7 +59,7 @@ pub(crate) fn unescape_byte(literal_text: &str) -> Result<u8, (usize, EscapeErro
59
59
60
60
/// Takes a contents of a string literal (without quotes) and produces a
61
61
/// sequence of escaped characters or errors.
62
- pub ( crate ) fn unescape_byte_str < F > ( literal_text : & str , callback : & mut F )
62
+ pub fn unescape_byte_str < F > ( literal_text : & str , callback : & mut F )
63
63
where
64
64
F : FnMut ( Range < usize > , Result < u8 , EscapeError > ) ,
65
65
{
72
72
/// sequence of characters or errors.
73
73
/// NOTE: Raw strings do not perform any explicit character escaping, here we
74
74
/// only translate CRLF to LF and produce errors on bare CR.
75
- pub ( crate ) fn unescape_raw_str < F > ( literal_text : & str , callback : & mut F )
75
+ pub fn unescape_raw_str < F > ( literal_text : & str , callback : & mut F )
76
76
where
77
77
F : FnMut ( Range < usize > , Result < char , EscapeError > ) ,
78
78
{
83
83
/// sequence of characters or errors.
84
84
/// NOTE: Raw strings do not perform any explicit character escaping, here we
85
85
/// only translate CRLF to LF and produce errors on bare CR.
86
- pub ( crate ) fn unescape_raw_byte_str < F > ( literal_text : & str , callback : & mut F )
86
+ pub fn unescape_raw_byte_str < F > ( literal_text : & str , callback : & mut F )
87
87
where
88
88
F : FnMut ( Range < usize > , Result < u8 , EscapeError > ) ,
89
89
{
@@ -93,26 +93,26 @@ where
93
93
}
94
94
95
95
#[ derive( Debug , Clone , Copy ) ]
96
- pub ( crate ) enum Mode {
96
+ pub enum Mode {
97
97
Char ,
98
98
Str ,
99
99
Byte ,
100
100
ByteStr ,
101
101
}
102
102
103
103
impl Mode {
104
- fn in_single_quotes ( self ) -> bool {
104
+ pub fn in_single_quotes ( self ) -> bool {
105
105
match self {
106
106
Mode :: Char | Mode :: Byte => true ,
107
107
Mode :: Str | Mode :: ByteStr => false ,
108
108
}
109
109
}
110
110
111
- pub ( crate ) fn in_double_quotes ( self ) -> bool {
111
+ pub fn in_double_quotes ( self ) -> bool {
112
112
!self . in_single_quotes ( )
113
113
}
114
114
115
- pub ( crate ) fn is_bytes ( self ) -> bool {
115
+ pub fn is_bytes ( self ) -> bool {
116
116
match self {
117
117
Mode :: Byte | Mode :: ByteStr => true ,
118
118
Mode :: Char | Mode :: Str => false ,
0 commit comments