Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2ba2ec4

Browse files
committed
refactor(display_list): Take a reference to StyleSheet
1 parent 113878a commit 2ba2ec4

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

‎src/display_list/mod.rs‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use crate::renderer::{stylesheet::Stylesheet, Margin, Style};
4040
/// List of lines to be displayed.
4141
pub(crate) struct DisplayList<'a> {
4242
pub body: Vec<DisplayLine<'a>>,
43-
pub stylesheet: Stylesheet,
43+
pub stylesheet: &'aStylesheet,
4444
pub anonymized_line_numbers: bool,
4545
pub margin: Option<Margin>,
4646
}
@@ -108,7 +108,7 @@ impl<'a> DisplayList<'a> {
108108
footer,
109109
slices,
110110
}: snippet::Snippet<'a>,
111-
stylesheet: Stylesheet,
111+
stylesheet: &'aStylesheet,
112112
anonymized_line_numbers: bool,
113113
margin: Option<Margin>,
114114
) -> DisplayList<'a> {
@@ -1217,7 +1217,7 @@ mod tests {
12171217
fn from_display_lines(lines: Vec<DisplayLine<'_>>) -> DisplayList<'_> {
12181218
DisplayList {
12191219
body: lines,
1220-
stylesheet: STYLESHEET,
1220+
stylesheet: &STYLESHEET,
12211221
anonymized_line_numbers: false,
12221222
margin: None,
12231223
}
@@ -1246,7 +1246,7 @@ mod tests {
12461246
source_aligned: false,
12471247
continuation: false,
12481248
})]);
1249-
assert_eq!(DisplayList::new(input, STYLESHEET, false, None), output);
1249+
assert_eq!(DisplayList::new(input, &STYLESHEET, false, None), output);
12501250
}
12511251

12521252
#[test]
@@ -1293,7 +1293,7 @@ mod tests {
12931293
line: DisplaySourceLine::Empty,
12941294
},
12951295
]);
1296-
assert_eq!(DisplayList::new(input, STYLESHEET, false, None), output);
1296+
assert_eq!(DisplayList::new(input, &STYLESHEET, false, None), output);
12971297
}
12981298

12991299
#[test]
@@ -1370,7 +1370,7 @@ mod tests {
13701370
line: DisplaySourceLine::Empty,
13711371
},
13721372
]);
1373-
assert_eq!(DisplayList::new(input, STYLESHEET, false, None), output);
1373+
assert_eq!(DisplayList::new(input, &STYLESHEET, false, None), output);
13741374
}
13751375

13761376
#[test]
@@ -1440,7 +1440,7 @@ mod tests {
14401440
line: DisplaySourceLine::Empty,
14411441
},
14421442
]);
1443-
assert_eq!(DisplayList::new(input, STYLESHEET, false, None), output);
1443+
assert_eq!(DisplayList::new(input, &STYLESHEET, false, None), output);
14441444
}
14451445

14461446
#[test]
@@ -1466,7 +1466,7 @@ mod tests {
14661466
source_aligned: true,
14671467
continuation: false,
14681468
})]);
1469-
assert_eq!(DisplayList::new(input, STYLESHEET, false, None), output);
1469+
assert_eq!(DisplayList::new(input, &STYLESHEET, false, None), output);
14701470
}
14711471

14721472
#[test]
@@ -1489,7 +1489,7 @@ mod tests {
14891489
fold: false,
14901490
}],
14911491
};
1492-
let _ = DisplayList::new(input, STYLESHEET, false, None);
1492+
let _ = DisplayList::new(input, &STYLESHEET, false, None);
14931493
}
14941494

14951495
#[test]
@@ -1577,7 +1577,7 @@ mod tests {
15771577
},
15781578
]);
15791579
assert_eq!(
1580-
DisplayList::new(snippets, STYLESHEET, false, None),
1580+
DisplayList::new(snippets, &STYLESHEET, false, None),
15811581
expected
15821582
);
15831583
}

‎src/renderer/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl Renderer {
9595
pub fn render<'a>(&'a self, snippet: Snippet<'a>) -> impl Display + 'a {
9696
DisplayList::new(
9797
snippet,
98-
self.stylesheet,
98+
&self.stylesheet,
9999
self.anonymized_line_numbers,
100100
self.margin,
101101
)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /