@@ -110,7 +110,7 @@ impl<'a> DisplayList<'a> {
110
110
title,
111
111
id,
112
112
footer,
113
- slices ,
113
+ snippets ,
114
114
} : snippet:: Message < ' a > ,
115
115
stylesheet : & ' a Stylesheet ,
116
116
anonymized_line_numbers : bool ,
@@ -120,9 +120,9 @@ impl<'a> DisplayList<'a> {
120
120
121
121
body. push ( format_title ( title, id) ) ;
122
122
123
- for ( idx, slice ) in slices . into_iter ( ) . enumerate ( ) {
123
+ for ( idx, snippet ) in snippets . into_iter ( ) . enumerate ( ) {
124
124
body. append ( & mut format_slice (
125
- slice ,
125
+ snippet ,
126
126
idx == 0 ,
127
127
!footer. is_empty ( ) ,
128
128
margin,
@@ -542,7 +542,7 @@ pub enum DisplayLine<'a> {
542
542
/// A source line.
543
543
#[ derive( Debug , PartialEq ) ]
544
544
pub enum DisplaySourceLine < ' a > {
545
- /// A line with the content of the Slice .
545
+ /// A line with the content of the Snippet .
546
546
Content {
547
547
text : & ' a str ,
548
548
range : ( usize , usize ) , // meta information for annotation placement.
@@ -762,15 +762,15 @@ fn format_footer(footer: snippet::Label<'_>) -> Vec<DisplayLine<'_>> {
762
762
}
763
763
764
764
fn format_slice (
765
- slice : snippet:: Slice < ' _ > ,
765
+ snippet : snippet:: Snippet < ' _ > ,
766
766
is_first : bool ,
767
767
has_footer : bool ,
768
768
margin : Option < Margin > ,
769
769
) -> Vec < DisplayLine < ' _ > > {
770
- let main_range = slice . annotations . first ( ) . map ( |x| x. range . start ) ;
771
- let origin = slice . origin ;
770
+ let main_range = snippet . annotations . first ( ) . map ( |x| x. range . start ) ;
771
+ let origin = snippet . origin ;
772
772
let need_empty_header = origin. is_some ( ) || is_first;
773
- let mut body = format_body ( slice , need_empty_header, has_footer, margin) ;
773
+ let mut body = format_body ( snippet , need_empty_header, has_footer, margin) ;
774
774
let header = format_header ( origin, main_range, & body, is_first) ;
775
775
let mut result = vec ! [ ] ;
776
776
@@ -942,13 +942,13 @@ fn fold_body(mut body: Vec<DisplayLine<'_>>) -> Vec<DisplayLine<'_>> {
942
942
}
943
943
944
944
fn format_body (
945
- slice : snippet:: Slice < ' _ > ,
945
+ snippet : snippet:: Snippet < ' _ > ,
946
946
need_empty_header : bool ,
947
947
has_footer : bool ,
948
948
margin : Option < Margin > ,
949
949
) -> Vec < DisplayLine < ' _ > > {
950
- let source_len = slice . source . len ( ) ;
951
- if let Some ( bigger) = slice . annotations . iter ( ) . find_map ( |x| {
950
+ let source_len = snippet . source . len ( ) ;
951
+ if let Some ( bigger) = snippet . annotations . iter ( ) . find_map ( |x| {
952
952
// Allow highlighting one past the last character in the source.
953
953
if source_len + 1 < x. range . end {
954
954
Some ( & x. range )
@@ -963,7 +963,7 @@ fn format_body(
963
963
}
964
964
965
965
let mut body = vec ! [ ] ;
966
- let mut current_line = slice . line_start ;
966
+ let mut current_line = snippet . line_start ;
967
967
let mut current_index = 0 ;
968
968
let mut line_info = vec ! [ ] ;
969
969
@@ -972,7 +972,7 @@ fn format_body(
972
972
line_end_index : usize ,
973
973
}
974
974
975
- for ( line, end_line) in CursorLines :: new ( slice . source ) {
975
+ for ( line, end_line) in CursorLines :: new ( snippet . source ) {
976
976
let line_length: usize = line
977
977
. chars ( )
978
978
. map ( |c| unicode_width:: UnicodeWidthChar :: width ( c) . unwrap_or ( 0 ) )
@@ -995,7 +995,7 @@ fn format_body(
995
995
}
996
996
997
997
let mut annotation_line_count = 0 ;
998
- let mut annotations = slice . annotations ;
998
+ let mut annotations = snippet . annotations ;
999
999
for (
1000
1000
idx,
1001
1001
LineInfo {
@@ -1143,7 +1143,7 @@ fn format_body(
1143
1143
} ) ;
1144
1144
}
1145
1145
1146
- if slice . fold {
1146
+ if snippet . fold {
1147
1147
body = fold_body ( body) ;
1148
1148
}
1149
1149
@@ -1227,7 +1227,7 @@ mod tests {
1227
1227
let line_1 = "This is line 1" ;
1228
1228
let line_2 = "This is line 2" ;
1229
1229
let source = [ line_1, line_2] . join ( "\n " ) ;
1230
- let input = snippet:: Message :: error ( "" ) . slice ( snippet:: Slice :: new ( & source, 5402 ) ) ;
1230
+ let input = snippet:: Message :: error ( "" ) . snippet ( snippet:: Snippet :: new ( & source, 5402 ) ) ;
1231
1231
let output = from_display_lines ( vec ! [
1232
1232
DisplayLine :: Raw ( DisplayRawLine :: Annotation {
1233
1233
annotation: Annotation {
@@ -1278,8 +1278,8 @@ mod tests {
1278
1278
let src_1 = "This is slice 2" ;
1279
1279
let src_1_len = src_1. len ( ) ;
1280
1280
let input = snippet:: Message :: error ( "" )
1281
- . slice ( snippet:: Slice :: new ( src_0, 5402 ) . origin ( "file1.rs" ) )
1282
- . slice ( snippet:: Slice :: new ( src_1, 2 ) . origin ( "file2.rs" ) ) ;
1281
+ . snippet ( snippet:: Snippet :: new ( src_0, 5402 ) . origin ( "file1.rs" ) )
1282
+ . snippet ( snippet:: Snippet :: new ( src_1, 2 ) . origin ( "file2.rs" ) ) ;
1283
1283
let output = from_display_lines ( vec ! [
1284
1284
DisplayLine :: Raw ( DisplayRawLine :: Annotation {
1285
1285
annotation: Annotation {
@@ -1350,8 +1350,8 @@ mod tests {
1350
1350
let source = [ line_1, line_2] . join ( "\n " ) ;
1351
1351
// In line 2
1352
1352
let range = 22 ..24 ;
1353
- let input = snippet:: Message :: error ( "" ) . slice (
1354
- snippet:: Slice :: new ( & source, 5402 )
1353
+ let input = snippet:: Message :: error ( "" ) . snippet (
1354
+ snippet:: Snippet :: new ( & source, 5402 )
1355
1355
. annotation ( snippet:: Label :: info ( "Test annotation" ) . span ( range. clone ( ) ) ) ,
1356
1356
) ;
1357
1357
let output = from_display_lines ( vec ! [
@@ -1455,17 +1455,17 @@ mod tests {
1455
1455
fn test_i26 ( ) {
1456
1456
let source = "short" ;
1457
1457
let label = "label" ;
1458
- let input = snippet:: Message :: error ( "" ) . slice (
1459
- snippet:: Slice :: new ( source, 0 )
1458
+ let input = snippet:: Message :: error ( "" ) . snippet (
1459
+ snippet:: Snippet :: new ( source, 0 )
1460
1460
. annotation ( snippet:: Label :: error ( label) . span ( 0 ..source. len ( ) + 2 ) ) ,
1461
1461
) ;
1462
1462
let _ = DisplayList :: new ( input, & STYLESHEET , false , None ) ;
1463
1463
}
1464
1464
1465
1465
#[ test]
1466
1466
fn test_i_29 ( ) {
1467
- let snippets = snippet:: Message :: error ( "oops" ) . slice (
1468
- snippet:: Slice :: new ( "First line\r \n Second oops line" , 1 )
1467
+ let snippets = snippet:: Message :: error ( "oops" ) . snippet (
1468
+ snippet:: Snippet :: new ( "First line\r \n Second oops line" , 1 )
1469
1469
. origin ( "<current file>" )
1470
1470
. fold ( true )
1471
1471
. annotation ( snippet:: Label :: error ( "oops" ) . span ( 19 ..23 ) ) ,
0 commit comments