Skip to content

Commit 9dd7d02

Browse files
committed
refactor(display_list): Take a reference to StyleSheet
1 parent 31cb75e commit 9dd7d02

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Diff for: src/display_list/mod.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use crate::renderer::StyleSheet;
4343
/// List of lines to be displayed.
4444
pub struct DisplayList<'a> {
4545
pub body: Vec<DisplayLine<'a>>,
46-
pub stylesheet: StyleSheet,
46+
pub stylesheet: &'a StyleSheet,
4747
pub anonymized_line_numbers: bool,
4848
pub margin: Option<Margin>,
4949
}
@@ -111,7 +111,7 @@ impl<'a> DisplayList<'a> {
111111
footer,
112112
slices,
113113
}: snippet::Snippet<'a>,
114-
stylesheet: StyleSheet,
114+
stylesheet: &'a StyleSheet,
115115
anonymized_line_numbers: bool,
116116
margin: Option<Margin>,
117117
) -> DisplayList<'a> {
@@ -1220,7 +1220,7 @@ mod tests {
12201220
fn from_display_lines(lines: Vec<DisplayLine<'_>>) -> DisplayList<'_> {
12211221
DisplayList {
12221222
body: lines,
1223-
stylesheet: STYLESHEET,
1223+
stylesheet: &STYLESHEET,
12241224
anonymized_line_numbers: false,
12251225
margin: None,
12261226
}
@@ -1249,7 +1249,7 @@ mod tests {
12491249
source_aligned: false,
12501250
continuation: false,
12511251
})]);
1252-
assert_eq!(DisplayList::new(input, STYLESHEET, false, None), output);
1252+
assert_eq!(DisplayList::new(input, &STYLESHEET, false, None), output);
12531253
}
12541254

12551255
#[test]
@@ -1296,7 +1296,7 @@ mod tests {
12961296
line: DisplaySourceLine::Empty,
12971297
},
12981298
]);
1299-
assert_eq!(DisplayList::new(input, STYLESHEET, false, None), output);
1299+
assert_eq!(DisplayList::new(input, &STYLESHEET, false, None), output);
13001300
}
13011301

13021302
#[test]
@@ -1373,7 +1373,7 @@ mod tests {
13731373
line: DisplaySourceLine::Empty,
13741374
},
13751375
]);
1376-
assert_eq!(DisplayList::new(input, STYLESHEET, false, None), output);
1376+
assert_eq!(DisplayList::new(input, &STYLESHEET, false, None), output);
13771377
}
13781378

13791379
#[test]
@@ -1443,7 +1443,7 @@ mod tests {
14431443
line: DisplaySourceLine::Empty,
14441444
},
14451445
]);
1446-
assert_eq!(DisplayList::new(input, STYLESHEET, false, None), output);
1446+
assert_eq!(DisplayList::new(input, &STYLESHEET, false, None), output);
14471447
}
14481448

14491449
#[test]
@@ -1469,7 +1469,7 @@ mod tests {
14691469
source_aligned: true,
14701470
continuation: false,
14711471
})]);
1472-
assert_eq!(DisplayList::new(input, STYLESHEET, false, None), output);
1472+
assert_eq!(DisplayList::new(input, &STYLESHEET, false, None), output);
14731473
}
14741474

14751475
#[test]
@@ -1492,7 +1492,7 @@ mod tests {
14921492
fold: false,
14931493
}],
14941494
};
1495-
let _ = DisplayList::new(input, STYLESHEET, false, None);
1495+
let _ = DisplayList::new(input, &STYLESHEET, false, None);
14961496
}
14971497

14981498
#[test]
@@ -1580,7 +1580,7 @@ mod tests {
15801580
},
15811581
]);
15821582
assert_eq!(
1583-
DisplayList::new(snippets, STYLESHEET, false, None),
1583+
DisplayList::new(snippets, &STYLESHEET, false, None),
15841584
expected
15851585
);
15861586
}

Diff for: src/renderer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl Renderer {
1717
pub fn render<'a>(&'a self, snippet: Snippet<'a>) -> impl Display + 'a {
1818
DisplayList::new(
1919
snippet,
20-
self.stylesheet,
20+
&self.stylesheet,
2121
self.anonymized_line_numbers,
2222
self.margin,
2323
)

0 commit comments

Comments
 (0)