@@ -4,29 +4,29 @@ pub(crate) mod printf {
44
55 /// Represents a single `printf`-style substitution.
66 #[ derive( Clone , PartialEq , Debug ) ]
7- pub enum Substitution < ' a > {
7+ pub ( crate ) enum Substitution < ' a > {
88 /// A formatted output substitution with its internal byte offset.
99 Format ( Format < ' a > ) ,
1010 /// A literal `%%` escape, with its start and end indices.
1111 Escape ( ( usize , usize ) ) ,
1212 }
1313
1414 impl < ' a > Substitution < ' a > {
15- pub fn as_str ( & self ) -> & str {
15+ pub ( crate ) fn as_str ( & self ) -> & str {
1616 match self {
1717 Substitution :: Format ( fmt) => fmt. span ,
1818 Substitution :: Escape ( _) => "%%" ,
1919 }
2020 }
2121
22- pub fn position ( & self ) -> InnerSpan {
22+ pub ( crate ) fn position ( & self ) -> InnerSpan {
2323 match self {
2424 Substitution :: Format ( fmt) => fmt. position ,
2525 & Substitution :: Escape ( ( start, end) ) => InnerSpan :: new ( start, end) ,
2626 }
2727 }
2828
29- pub fn set_position ( & mut self , start : usize , end : usize ) {
29+ pub ( crate ) fn set_position ( & mut self , start : usize , end : usize ) {
3030 match self {
3131 Substitution :: Format ( fmt) => fmt. position = InnerSpan :: new ( start, end) ,
3232 Substitution :: Escape ( pos) => * pos = ( start, end) ,
@@ -37,7 +37,7 @@ pub(crate) mod printf {
3737 ///
3838 /// This ignores cases where the substitution does not have an exact equivalent, or where
3939 /// the substitution would be unnecessary.
40- pub fn translate ( & self ) -> Result < String , Option < String > > {
40+ pub ( crate ) fn translate ( & self ) -> Result < String , Option < String > > {
4141 match self {
4242 Substitution :: Format ( fmt) => fmt. translate ( ) ,
4343 Substitution :: Escape ( _) => Err ( None ) ,
@@ -47,31 +47,31 @@ pub(crate) mod printf {
4747
4848 #[ derive( Clone , PartialEq , Debug ) ]
4949 /// A single `printf`-style formatting directive.
50- pub struct Format < ' a > {
50+ pub ( crate ) struct Format < ' a > {
5151 /// The entire original formatting directive.
52- pub span : & ' a str ,
52+ span : & ' a str ,
5353 /// The (1-based) parameter to be converted.
54- pub parameter : Option < u16 > ,
54+ parameter : Option < u16 > ,
5555 /// Formatting flags.
56- pub flags : & ' a str ,
56+ flags : & ' a str ,
5757 /// Minimum width of the output.
58- pub width : Option < Num > ,
58+ width : Option < Num > ,
5959 /// Precision of the conversion.
60- pub precision : Option < Num > ,
60+ precision : Option < Num > ,
6161 /// Length modifier for the conversion.
62- pub length : Option < & ' a str > ,
62+ length : Option < & ' a str > ,
6363 /// Type of parameter being converted.
64- pub type_ : & ' a str ,
64+ type_ : & ' a str ,
6565 /// Byte offset for the start and end of this formatting directive.
66- pub position : InnerSpan ,
66+ position : InnerSpan ,
6767 }
6868
6969 impl Format < ' _ > {
7070 /// Translate this directive into an equivalent Rust formatting directive.
7171 ///
7272 /// Returns `Err` in cases where the `printf` directive does not have an exact Rust
7373 /// equivalent, rather than guessing.
74- pub fn translate ( & self ) -> Result < String , Option < String > > {
74+ pub ( crate ) fn translate ( & self ) -> Result < String , Option < String > > {
7575 use std:: fmt:: Write ;
7676
7777 let ( c_alt, c_zero, c_left, c_plus) = {
@@ -248,7 +248,7 @@ pub(crate) mod printf {
248248
249249 /// A general number used in a `printf` formatting directive.
250250 #[ derive( Copy , Clone , PartialEq , Debug ) ]
251- pub enum Num {
251+ enum Num {
252252 // The range of these values is technically bounded by `NL_ARGMAX`... but, at least for GNU
253253 // libc, it apparently has no real fixed limit. A `u16` is used here on the basis that it
254254 // is *vanishingly* unlikely that *anyone* is going to try formatting something wider, or
@@ -287,12 +287,12 @@ pub(crate) mod printf {
287287 }
288288
289289 /// Returns an iterator over all substitutions in a given string.
290- pub fn iter_subs ( s : & str , start_pos : usize ) -> Substitutions < ' _ > {
290+ pub ( crate ) fn iter_subs ( s : & str , start_pos : usize ) -> Substitutions < ' _ > {
291291 Substitutions { s, pos : start_pos }
292292 }
293293
294294 /// Iterator over substitutions in a string.
295- pub struct Substitutions < ' a > {
295+ pub ( crate ) struct Substitutions < ' a > {
296296 s : & ' a str ,
297297 pos : usize ,
298298 }
@@ -326,7 +326,7 @@ pub(crate) mod printf {
326326 }
327327
328328 /// Parse the next substitution from the input string.
329- pub fn parse_next_substitution ( s : & str ) -> Option < ( Substitution < ' _ > , & str ) > {
329+ fn parse_next_substitution ( s : & str ) -> Option < ( Substitution < ' _ > , & str ) > {
330330 use self :: State :: * ;
331331
332332 let at = {
@@ -614,37 +614,37 @@ pub(crate) mod printf {
614614 mod tests;
615615}
616616
617- pub mod shell {
617+ pub ( crate ) mod shell {
618618 use super :: strcursor:: StrCursor as Cur ;
619619 use rustc_span:: InnerSpan ;
620620
621621 #[ derive( Clone , PartialEq , Debug ) ]
622- pub enum Substitution < ' a > {
622+ pub ( crate ) enum Substitution < ' a > {
623623 Ordinal ( u8 , ( usize , usize ) ) ,
624624 Name ( & ' a str , ( usize , usize ) ) ,
625625 Escape ( ( usize , usize ) ) ,
626626 }
627627
628628 impl Substitution < ' _ > {
629- pub fn as_str ( & self ) -> String {
629+ pub ( crate ) fn as_str ( & self ) -> String {
630630 match self {
631631 Substitution :: Ordinal ( n, _) => format ! ( "${n}" ) ,
632632 Substitution :: Name ( n, _) => format ! ( "${n}" ) ,
633633 Substitution :: Escape ( _) => "$$" . into ( ) ,
634634 }
635635 }
636636
637- pub fn position ( & self ) -> InnerSpan {
637+ pub ( crate ) fn position ( & self ) -> InnerSpan {
638638 let ( Self :: Ordinal ( _, pos) | Self :: Name ( _, pos) | Self :: Escape ( pos) ) = self ;
639639 InnerSpan :: new ( pos. 0 , pos. 1 )
640640 }
641641
642- pub fn set_position ( & mut self , start : usize , end : usize ) {
642+ fn set_position ( & mut self , start : usize , end : usize ) {
643643 let ( Self :: Ordinal ( _, pos) | Self :: Name ( _, pos) | Self :: Escape ( pos) ) = self ;
644644 * pos = ( start, end) ;
645645 }
646646
647- pub fn translate ( & self ) -> Result < String , Option < String > > {
647+ pub ( crate ) fn translate ( & self ) -> Result < String , Option < String > > {
648648 match self {
649649 Substitution :: Ordinal ( n, _) => Ok ( format ! ( "{{{}}}" , n) ) ,
650650 Substitution :: Name ( n, _) => Ok ( format ! ( "{{{}}}" , n) ) ,
@@ -654,12 +654,12 @@ pub mod shell {
654654 }
655655
656656 /// Returns an iterator over all substitutions in a given string.
657- pub fn iter_subs ( s : & str , start_pos : usize ) -> Substitutions < ' _ > {
657+ pub ( crate ) fn iter_subs ( s : & str , start_pos : usize ) -> Substitutions < ' _ > {
658658 Substitutions { s, pos : start_pos }
659659 }
660660
661661 /// Iterator over substitutions in a string.
662- pub struct Substitutions < ' a > {
662+ pub ( crate ) struct Substitutions < ' a > {
663663 s : & ' a str ,
664664 pos : usize ,
665665 }
@@ -681,7 +681,7 @@ pub mod shell {
681681 }
682682
683683 /// Parse the next substitution from the input string.
684- pub fn parse_next_substitution ( s : & str ) -> Option < ( Substitution < ' _ > , & str ) > {
684+ fn parse_next_substitution ( s : & str ) -> Option < ( Substitution < ' _ > , & str ) > {
685685 let at = {
686686 let start = s. find ( '$' ) ?;
687687 match s[ start + 1 ..] . chars ( ) . next ( ) ? {
@@ -741,24 +741,24 @@ pub mod shell {
741741}
742742
743743mod strcursor {
744- pub struct StrCursor < ' a > {
744+ pub ( crate ) struct StrCursor < ' a > {
745745 s : & ' a str ,
746746 pub at : usize ,
747747 }
748748
749749 impl < ' a > StrCursor < ' a > {
750- pub fn new_at ( s : & ' a str , at : usize ) -> StrCursor < ' a > {
750+ pub ( crate ) fn new_at ( s : & ' a str , at : usize ) -> StrCursor < ' a > {
751751 StrCursor { s, at }
752752 }
753753
754- pub fn at_next_cp ( mut self ) -> Option < StrCursor < ' a > > {
754+ pub ( crate ) fn at_next_cp ( mut self ) -> Option < StrCursor < ' a > > {
755755 match self . try_seek_right_cp ( ) {
756756 true => Some ( self ) ,
757757 false => None ,
758758 }
759759 }
760760
761- pub fn next_cp ( mut self ) -> Option < ( char , StrCursor < ' a > ) > {
761+ pub ( crate ) fn next_cp ( mut self ) -> Option < ( char , StrCursor < ' a > ) > {
762762 let cp = self . cp_after ( ) ?;
763763 self . seek_right ( cp. len_utf8 ( ) ) ;
764764 Some ( ( cp, self ) )
@@ -768,11 +768,11 @@ mod strcursor {
768768 & self . s [ 0 ..self . at ]
769769 }
770770
771- pub fn slice_after ( & self ) -> & ' a str {
771+ pub ( crate ) fn slice_after ( & self ) -> & ' a str {
772772 & self . s [ self . at ..]
773773 }
774774
775- pub fn slice_between ( & self , until : StrCursor < ' a > ) -> Option < & ' a str > {
775+ pub ( crate ) fn slice_between ( & self , until : StrCursor < ' a > ) -> Option < & ' a str > {
776776 if !str_eq_literal ( self . s , until. s ) {
777777 None
778778 } else {
0 commit comments