Skip to content

Commit ecc291d

Browse files
committed
Store a slice ref not a vec
1 parent 2039b3f commit ecc291d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
/// The low-level macros used by this crate.
3030
pub use include_flate_codegen as codegen;
3131
use include_flate_compress::apply_decompression;
32+
use std::string::FromUtf8Error;
3233

33-
#[doc(hidden)]
3434
pub use include_flate_compress::CompressionMethod;
3535

3636
/// This macro is like [`include_bytes!`][1] or [`include_str!`][2], but compresses at compile time
@@ -129,21 +129,21 @@ macro_rules! flate {
129129
"zstd" => $crate::CompressionMethod::Zstd,
130130
_ => $crate::CompressionMethod::default(),
131131
};
132-
let compressed = $crate::codegen::deflate_file!($path $($algo)?).to_vec();
132+
let compressed = $crate::codegen::deflate_file!($path $($algo)?);
133133
$crate::IFlate::new(compressed, algo)
134134
});
135135
};
136136
}
137137

138138
#[derive(Debug)]
139139
pub struct IFlate {
140-
compressed: Vec<u8>,
140+
compressed: &'static [u8],
141141
algo: CompressionMethod,
142142
}
143143

144144
impl IFlate {
145145
#[doc(hidden)]
146-
pub fn new(compressed: Vec<u8>, algo: CompressionMethod) -> Self {
146+
pub fn new(compressed: &'static [u8], algo: CompressionMethod) -> Self {
147147
Self { compressed, algo }
148148
}
149149

@@ -155,7 +155,7 @@ impl IFlate {
155155
decode(&self.compressed, Some(CompressionMethodTy(self.algo)))
156156
}
157157

158-
pub fn decode_string(&self) -> Result<String, std::string::FromUtf8Error> {
158+
pub fn decode_string(&self) -> Result<String, FromUtf8Error> {
159159
String::from_utf8(self.decoded())
160160
}
161161

0 commit comments

Comments
 (0)