1- //! display_list module stores the output model for the snippet.
1+ //!` display_list` module stores the output model for the snippet.
22//!
33//! `DisplayList` is a central structure in the crate, which contains
44//! the structured list of lines to be displayed.
@@ -48,9 +48,9 @@ const WARNING_TXT: &str = "warning";
4848
4949/// List of lines to be displayed.
5050pub ( 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 ,
5454}
5555
5656impl < ' a > PartialEq for DisplayList < ' a > {
@@ -147,8 +147,8 @@ impl<'a> DisplayList<'a> {
147147
148148#[ derive( Debug , PartialEq ) ]
149149pub ( 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 ,
152152}
153153
154154impl < ' a > DisplaySet < ' a > {
@@ -493,15 +493,15 @@ impl<'a> DisplaySet<'a> {
493493
494494/// Inline annotation which can be used in either Raw or Source line.
495495#[ 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 > > ,
500500}
501501
502502/// A single line used in `DisplayList`.
503503#[ derive( Debug , PartialEq ) ]
504- pub enum DisplayLine < ' a > {
504+ pub ( crate ) enum DisplayLine < ' a > {
505505/// A line with `lineno` portion of the slice.
506506Source {
507507lineno : Option < usize > ,
@@ -519,7 +519,7 @@ pub enum DisplayLine<'a> {
519519
520520/// A source line.
521521#[ derive( Debug , PartialEq ) ]
522- pub enum DisplaySourceLine < ' a > {
522+ pub ( crate ) enum DisplaySourceLine < ' a > {
523523/// A line with the content of the Snippet.
524524Content {
525525text : & ' a str ,
@@ -530,17 +530,17 @@ pub enum DisplaySourceLine<'a> {
530530}
531531
532532#[ 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 ,
538538}
539539
540540/// Raw line - a line which does not have the `lineno` part and is not considered
541541/// a part of the snippet.
542542#[ derive( Debug , PartialEq ) ]
543- pub enum DisplayRawLine < ' a > {
543+ pub ( crate ) enum DisplayRawLine < ' a > {
544544/// A line which provides information about the location of the given
545545/// slice in the project structure.
546546Origin {
@@ -566,23 +566,23 @@ pub enum DisplayRawLine<'a> {
566566
567567/// An inline text fragment which any label is composed of.
568568#[ 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 ,
572572}
573573
574574/// A style for the `DisplayTextFragment` which can be visually formatted.
575575///
576576/// This information may be used to emphasis parts of the label.
577577#[ derive( Debug , Clone , Copy , PartialEq ) ]
578- pub enum DisplayTextStyle {
578+ pub ( crate ) enum DisplayTextStyle {
579579Regular ,
580580Emphasis ,
581581}
582582
583583/// An indicator of what part of the annotation a given `Annotation` is.
584584#[ derive( Debug , Clone , PartialEq ) ]
585- pub enum DisplayAnnotationPart {
585+ pub ( crate ) enum DisplayAnnotationPart {
586586/// A standalone, single-line annotation.
587587Standalone ,
588588/// A continuation of a multi-line label of an annotation.
@@ -595,14 +595,14 @@ pub enum DisplayAnnotationPart {
595595
596596/// A visual mark used in `inline_marks` field of the `DisplaySourceLine`.
597597#[ 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 ,
601601}
602602
603603/// A type of the `DisplayMark`.
604604#[ derive( Debug , Clone , PartialEq ) ]
605- pub enum DisplayMarkType {
605+ pub ( crate ) enum DisplayMarkType {
606606/// A mark indicating a multiline annotation going through the current line.
607607AnnotationThrough ,
608608/// A mark indicating a multiline annotation starting on the given line.
@@ -617,7 +617,7 @@ pub enum DisplayMarkType {
617617/// * An underline for `Error` may be `^^^` while for `Warning` it could be `---`.
618618/// * `ColorStylesheet` may use different colors for different annotations.
619619#[ derive( Debug , Clone , PartialEq ) ]
620- pub enum DisplayAnnotationType {
620+ pub ( crate ) enum DisplayAnnotationType {
621621None ,
622622Error ,
623623Warning ,
@@ -642,7 +642,7 @@ impl From<snippet::Level> for DisplayAnnotationType {
642642/// for multi-slice cases.
643643// TODO: private
644644#[ derive( Debug , Clone , PartialEq ) ]
645- pub enum DisplayHeaderType {
645+ pub ( crate ) enum DisplayHeaderType {
646646/// Initial header is the first header in the snippet.
647647Initial ,
648648
@@ -728,9 +728,9 @@ fn format_message(
728728}
729729
730730if let Some ( first) = sets. first_mut ( ) {
731- body . into_iter ( ) . for_each ( | line| {
731+ for linein body {
732732 first. display_lines . insert ( 0 , line) ;
733- } ) ;
733+ }
734734} else {
735735 sets. push ( DisplaySet {
736736display_lines : body,
@@ -1335,7 +1335,7 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
13351335] ;
13361336
13371337fn normalize_whitespace ( str : & str ) ->String {
1338- let mut s = str. to_string ( ) ;
1338+ let mut s = str. to_owned ( ) ;
13391339for ( c, replacement) in OUTPUT_REPLACEMENTS {
13401340 s = s. replace ( * c, replacement) ;
13411341}