8 ms·
Not sure if it’s an exact parallel, but you can also embed files into rust binaries with “include_bytes!” and “include_str!”.
by TrustPatches 4y ago
Not sure if it’s an exact parallel, but you can also embed files into rust binaries with “include_bytes!” and “include_str!”.
- 5e92cb50239222b 4y agoIt's a bit more advanced than what Rust macros provided last time I checked. You can shove whole directories in there and then traverse them or serve as static resources with pretty much one line of code. Random blog post with a few examples: https://blog.carlmjohnson.net/post/2021/how-to-use-go-embed/ https://blog.carlmjohnson.net/post/2021/how-to-use-go-embed/
- TrustPatches 4y agoVery cool, I guess one the the advantages of rust macros is that you could write your own to do something more advanced in theory
- super_flanker 4y agoYou can do the same in Rust with include_dir[1] 1: https://docs.rs/include_dir/latest/include_dir/ https://docs.rs/include_dir/latest/include_dir/
- scruple 4y agoI've gone as far as embedding a ReactJS app inside of Go's embedFS. It's pretty damn powerful.