Skip to content

Commit 7ee7aa7

Browse files
authored
Merge pull request steveklabnik#101 from euclio/assets
store asset contents as bytes
2 parents 2581fba + b1dfe60 commit 7ee7aa7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl fmt::Display for Asset {
117117
format!(
118118
r#"rustdoc::assets::Asset {{
119119
name: "{name}",
120-
contents: include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/{path}")),
120+
contents: include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/{path}")),
121121
}}"#,
122122
name = name,
123123
path = self.path,

src/assets.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct Asset {
1313
pub name: &'static str,
1414

1515
/// Contents of the file
16-
pub contents: &'static str,
16+
pub contents: &'static [u8],
1717
}
1818

1919
/// Output an asset file to a given directory
@@ -23,7 +23,7 @@ pub struct Asset {
2323
/// - name: Name of the asset file
2424
/// - path: Path to the directory to write the file out to
2525
/// - data: Data to be written to the file
26-
pub fn create_asset_file(name: &str, path: &Path, data: &str) -> Result<()> {
26+
pub fn create_asset_file(name: &str, path: &Path, data: &[u8]) -> Result<()> {
2727
let mut asset_path = path.to_path_buf();
2828
asset_path.push(name);
2929

@@ -36,7 +36,7 @@ pub fn create_asset_file(name: &str, path: &Path, data: &str) -> Result<()> {
3636
}
3737

3838
let mut file = File::create(asset_path)?;
39-
file.write_all(data.as_bytes())?;
39+
file.write_all(data)?;
4040

4141
Ok(())
4242
}

0 commit comments

Comments
 (0)