2
2
3
3
use proc_macro:: { token_stream, Group , TokenTree } ;
4
4
5
- pub fn try_ident ( it : & mut token_stream:: IntoIter ) -> Option < String > {
5
+ pub ( crate ) fn try_ident ( it : & mut token_stream:: IntoIter ) -> Option < String > {
6
6
if let Some ( TokenTree :: Ident ( ident) ) = it. next ( ) {
7
7
Some ( ident. to_string ( ) )
8
8
} else {
9
9
None
10
10
}
11
11
}
12
12
13
- pub fn try_literal ( it : & mut token_stream:: IntoIter ) -> Option < String > {
13
+ pub ( crate ) fn try_literal ( it : & mut token_stream:: IntoIter ) -> Option < String > {
14
14
if let Some ( TokenTree :: Literal ( literal) ) = it. next ( ) {
15
15
Some ( literal. to_string ( ) )
16
16
} else {
17
17
None
18
18
}
19
19
}
20
20
21
- pub fn try_byte_string ( it : & mut token_stream:: IntoIter ) -> Option < String > {
21
+ pub ( crate ) fn try_byte_string ( it : & mut token_stream:: IntoIter ) -> Option < String > {
22
22
try_literal ( it) . and_then ( |byte_string| {
23
23
if byte_string. starts_with ( "b\" " ) && byte_string. ends_with ( '\"' ) {
24
24
Some ( byte_string[ 2 ..byte_string. len ( ) - 1 ] . to_string ( ) )
@@ -28,49 +28,49 @@ pub fn try_byte_string(it: &mut token_stream::IntoIter) -> Option<String> {
28
28
} )
29
29
}
30
30
31
- pub fn expect_ident ( it : & mut token_stream:: IntoIter ) -> String {
31
+ pub ( crate ) fn expect_ident ( it : & mut token_stream:: IntoIter ) -> String {
32
32
try_ident ( it) . expect ( "Expected Ident" )
33
33
}
34
34
35
- pub fn expect_punct ( it : & mut token_stream:: IntoIter ) -> char {
35
+ pub ( crate ) fn expect_punct ( it : & mut token_stream:: IntoIter ) -> char {
36
36
if let TokenTree :: Punct ( punct) = it. next ( ) . expect ( "Reached end of token stream for Punct" ) {
37
37
punct. as_char ( )
38
38
} else {
39
39
panic ! ( "Expected Punct" ) ;
40
40
}
41
41
}
42
42
43
- pub fn expect_literal ( it : & mut token_stream:: IntoIter ) -> String {
43
+ pub ( crate ) fn expect_literal ( it : & mut token_stream:: IntoIter ) -> String {
44
44
try_literal ( it) . expect ( "Expected Literal" )
45
45
}
46
46
47
- pub fn expect_group ( it : & mut token_stream:: IntoIter ) -> Group {
47
+ pub ( crate ) fn expect_group ( it : & mut token_stream:: IntoIter ) -> Group {
48
48
if let TokenTree :: Group ( group) = it. next ( ) . expect ( "Reached end of token stream for Group" ) {
49
49
group
50
50
} else {
51
51
panic ! ( "Expected Group" ) ;
52
52
}
53
53
}
54
54
55
- pub fn expect_byte_string ( it : & mut token_stream:: IntoIter ) -> String {
55
+ pub ( crate ) fn expect_byte_string ( it : & mut token_stream:: IntoIter ) -> String {
56
56
try_byte_string ( it) . expect ( "Expected byte string" )
57
57
}
58
58
59
- pub fn expect_end ( it : & mut token_stream:: IntoIter ) {
59
+ pub ( crate ) fn expect_end ( it : & mut token_stream:: IntoIter ) {
60
60
if it. next ( ) . is_some ( ) {
61
61
panic ! ( "Expected end" ) ;
62
62
}
63
63
}
64
64
65
- pub fn get_literal ( it : & mut token_stream:: IntoIter , expected_name : & str ) -> String {
65
+ pub ( crate ) fn get_literal ( it : & mut token_stream:: IntoIter , expected_name : & str ) -> String {
66
66
assert_eq ! ( expect_ident( it) , expected_name) ;
67
67
assert_eq ! ( expect_punct( it) , ':' ) ;
68
68
let literal = expect_literal ( it) ;
69
69
assert_eq ! ( expect_punct( it) , ',' ) ;
70
70
literal
71
71
}
72
72
73
- pub fn get_byte_string ( it : & mut token_stream:: IntoIter , expected_name : & str ) -> String {
73
+ pub ( crate ) fn get_byte_string ( it : & mut token_stream:: IntoIter , expected_name : & str ) -> String {
74
74
assert_eq ! ( expect_ident( it) , expected_name) ;
75
75
assert_eq ! ( expect_punct( it) , ':' ) ;
76
76
let byte_string = expect_byte_string ( it) ;
0 commit comments