Lambda
unread,5:54 AM (13 hours ago) 5:54 AMSign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rust-em...@googlegroups.com
`const` items are always inlined, which is a problem because `ENTRIES`
is used both to find the index of the requested file and to retrieve its
content. In release builds, this is usually optimized away, but with the
`debug-embed` feature enabled, the entire embedded data is reliably
embedded twice in the binary:
$ cargo build --quiet --example basic --features debug-embed && \
strings target/debug/examples/basic | grep -F console.log
main.jsconsole.log("Awesomeness we can has")
main.jsconsole.log("Awesomeness we can has")
---
impl/src/lib.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/impl/src/lib.rs b/impl/src/lib.rs
index 15e8974..c22bd21 100644
--- a/impl/src/lib.rs
+++ b/impl/src/lib.rs
@@ -80,7 +80,7 @@ fn embedded(
pub fn get(file_path: &str) ->
::std::option::Option<#crate_path::EmbeddedFile> {
#handle_prefix
let key = file_path.replace("\\", "/");
- const ENTRIES: &'static [(&'static str, #value_type)] = &[
+ static ENTRIES: &'static [(&'static str, #value_type)] = &[
#(#match_values)*];
let position = ENTRIES.binary_search_by_key(&key.as_str(),
|entry| entry.0);
position.ok().map(#get_value)
--
2.54.0