Skip to content

Commit ba20da1

Browse files
committed
Make ExternalHtml::load short-circuited.
1 parent 7be14ee commit ba20da1

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/librustdoc/externalfiles.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,22 @@ pub struct ExternalHtml{
3030
impl ExternalHtml {
3131
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String])
3232
-> Option<ExternalHtml> {
33-
match (load_external_files(in_header),
34-
load_external_files(before_content),
35-
load_external_files(after_content)) {
36-
(Some(ih), Some(bc), Some(ac)) => Some(ExternalHtml {
37-
in_header: ih,
38-
before_content: bc,
39-
after_content: ac
40-
}),
41-
_ => None
42-
}
33+
load_external_files(in_header)
34+
.and_then(|ih|
35+
load_external_files(before_content)
36+
.map(|bc| (ih, bc))
37+
)
38+
.and_then(|(ih, bc)|
39+
load_external_files(after_content)
40+
.map(|ac| (ih, bc, ac))
41+
)
42+
.map(|(ih, bc, ac)|
43+
ExternalHtml {
44+
in_header: ih,
45+
before_content: bc,
46+
after_content: ac,
47+
}
48+
)
4349
}
4450
}
4551

0 commit comments

Comments
 (0)