1
- //! display_list module stores the output model for the snippet.
1
+ //! ` display_list` module stores the output model for the snippet.
2
2
//!
3
3
//! `DisplayList` is a central structure in the crate, which contains
4
4
//! the structured list of lines to be displayed.
@@ -48,9 +48,9 @@ const WARNING_TXT: &str = "warning";
48
48
49
49
/// List of lines to be displayed.
50
50
pub ( crate ) struct DisplayList < ' a > {
51
- pub body : Vec < DisplaySet < ' a > > ,
52
- pub stylesheet : & ' a Stylesheet ,
53
- pub anonymized_line_numbers : bool ,
51
+ pub ( crate ) body : Vec < DisplaySet < ' a > > ,
52
+ pub ( crate ) stylesheet : & ' a Stylesheet ,
53
+ pub ( crate ) anonymized_line_numbers : bool ,
54
54
}
55
55
56
56
impl < ' a > PartialEq for DisplayList < ' a > {
@@ -147,8 +147,8 @@ impl<'a> DisplayList<'a> {
147
147
148
148
#[ derive( Debug , PartialEq ) ]
149
149
pub ( crate ) struct DisplaySet < ' a > {
150
- pub display_lines : Vec < DisplayLine < ' a > > ,
151
- pub margin : Margin ,
150
+ pub ( crate ) display_lines : Vec < DisplayLine < ' a > > ,
151
+ pub ( crate ) margin : Margin ,
152
152
}
153
153
154
154
impl < ' a > DisplaySet < ' a > {
@@ -493,15 +493,15 @@ impl<'a> DisplaySet<'a> {
493
493
494
494
/// Inline annotation which can be used in either Raw or Source line.
495
495
#[ derive( Debug , PartialEq ) ]
496
- pub struct Annotation < ' a > {
497
- pub annotation_type : DisplayAnnotationType ,
498
- pub id : Option < & ' a str > ,
499
- pub label : Vec < DisplayTextFragment < ' a > > ,
496
+ pub ( crate ) struct Annotation < ' a > {
497
+ pub ( crate ) annotation_type : DisplayAnnotationType ,
498
+ pub ( crate ) id : Option < & ' a str > ,
499
+ pub ( crate ) label : Vec < DisplayTextFragment < ' a > > ,
500
500
}
501
501
502
502
/// A single line used in `DisplayList`.
503
503
#[ derive( Debug , PartialEq ) ]
504
- pub enum DisplayLine < ' a > {
504
+ pub ( crate ) enum DisplayLine < ' a > {
505
505
/// A line with `lineno` portion of the slice.
506
506
Source {
507
507
lineno : Option < usize > ,
@@ -519,7 +519,7 @@ pub enum DisplayLine<'a> {
519
519
520
520
/// A source line.
521
521
#[ derive( Debug , PartialEq ) ]
522
- pub enum DisplaySourceLine < ' a > {
522
+ pub ( crate ) enum DisplaySourceLine < ' a > {
523
523
/// A line with the content of the Snippet.
524
524
Content {
525
525
text : & ' a str ,
@@ -530,17 +530,17 @@ pub enum DisplaySourceLine<'a> {
530
530
}
531
531
532
532
#[ derive( Debug , PartialEq ) ]
533
- pub struct DisplaySourceAnnotation < ' a > {
534
- pub annotation : Annotation < ' a > ,
535
- pub range : ( usize , usize ) ,
536
- pub annotation_type : DisplayAnnotationType ,
537
- pub annotation_part : DisplayAnnotationPart ,
533
+ pub ( crate ) struct DisplaySourceAnnotation < ' a > {
534
+ pub ( crate ) annotation : Annotation < ' a > ,
535
+ pub ( crate ) range : ( usize , usize ) ,
536
+ pub ( crate ) annotation_type : DisplayAnnotationType ,
537
+ pub ( crate ) annotation_part : DisplayAnnotationPart ,
538
538
}
539
539
540
540
/// Raw line - a line which does not have the `lineno` part and is not considered
541
541
/// a part of the snippet.
542
542
#[ derive( Debug , PartialEq ) ]
543
- pub enum DisplayRawLine < ' a > {
543
+ pub ( crate ) enum DisplayRawLine < ' a > {
544
544
/// A line which provides information about the location of the given
545
545
/// slice in the project structure.
546
546
Origin {
@@ -566,23 +566,23 @@ pub enum DisplayRawLine<'a> {
566
566
567
567
/// An inline text fragment which any label is composed of.
568
568
#[ derive( Debug , PartialEq ) ]
569
- pub struct DisplayTextFragment < ' a > {
570
- pub content : & ' a str ,
571
- pub style : DisplayTextStyle ,
569
+ pub ( crate ) struct DisplayTextFragment < ' a > {
570
+ pub ( crate ) content : & ' a str ,
571
+ pub ( crate ) style : DisplayTextStyle ,
572
572
}
573
573
574
574
/// A style for the `DisplayTextFragment` which can be visually formatted.
575
575
///
576
576
/// This information may be used to emphasis parts of the label.
577
577
#[ derive( Debug , Clone , Copy , PartialEq ) ]
578
- pub enum DisplayTextStyle {
578
+ pub ( crate ) enum DisplayTextStyle {
579
579
Regular ,
580
580
Emphasis ,
581
581
}
582
582
583
583
/// An indicator of what part of the annotation a given `Annotation` is.
584
584
#[ derive( Debug , Clone , PartialEq ) ]
585
- pub enum DisplayAnnotationPart {
585
+ pub ( crate ) enum DisplayAnnotationPart {
586
586
/// A standalone, single-line annotation.
587
587
Standalone ,
588
588
/// A continuation of a multi-line label of an annotation.
@@ -595,14 +595,14 @@ pub enum DisplayAnnotationPart {
595
595
596
596
/// A visual mark used in `inline_marks` field of the `DisplaySourceLine`.
597
597
#[ derive( Debug , Clone , PartialEq ) ]
598
- pub struct DisplayMark {
599
- pub mark_type : DisplayMarkType ,
600
- pub annotation_type : DisplayAnnotationType ,
598
+ pub ( crate ) struct DisplayMark {
599
+ pub ( crate ) mark_type : DisplayMarkType ,
600
+ pub ( crate ) annotation_type : DisplayAnnotationType ,
601
601
}
602
602
603
603
/// A type of the `DisplayMark`.
604
604
#[ derive( Debug , Clone , PartialEq ) ]
605
- pub enum DisplayMarkType {
605
+ pub ( crate ) enum DisplayMarkType {
606
606
/// A mark indicating a multiline annotation going through the current line.
607
607
AnnotationThrough ,
608
608
/// A mark indicating a multiline annotation starting on the given line.
@@ -617,7 +617,7 @@ pub enum DisplayMarkType {
617
617
/// * An underline for `Error` may be `^^^` while for `Warning` it could be `---`.
618
618
/// * `ColorStylesheet` may use different colors for different annotations.
619
619
#[ derive( Debug , Clone , PartialEq ) ]
620
- pub enum DisplayAnnotationType {
620
+ pub ( crate ) enum DisplayAnnotationType {
621
621
None ,
622
622
Error ,
623
623
Warning ,
@@ -642,7 +642,7 @@ impl From<snippet::Level> for DisplayAnnotationType {
642
642
/// for multi-slice cases.
643
643
// TODO: private
644
644
#[ derive( Debug , Clone , PartialEq ) ]
645
- pub enum DisplayHeaderType {
645
+ pub ( crate ) enum DisplayHeaderType {
646
646
/// Initial header is the first header in the snippet.
647
647
Initial ,
648
648
@@ -728,9 +728,9 @@ fn format_message(
728
728
}
729
729
730
730
if let Some ( first) = sets. first_mut ( ) {
731
- body . into_iter ( ) . for_each ( | line| {
731
+ for line in body {
732
732
first. display_lines . insert ( 0 , line) ;
733
- } ) ;
733
+ }
734
734
} else {
735
735
sets. push ( DisplaySet {
736
736
display_lines : body,
@@ -1335,7 +1335,7 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
1335
1335
] ;
1336
1336
1337
1337
fn normalize_whitespace ( str : & str ) -> String {
1338
- let mut s = str. to_string ( ) ;
1338
+ let mut s = str. to_owned ( ) ;
1339
1339
for ( c, replacement) in OUTPUT_REPLACEMENTS {
1340
1340
s = s. replace ( * c, replacement) ;
1341
1341
}
0 commit comments