3 ms·
You can check out a number of strategies for reducing rust binary size here: https://github.com/johnthagen/min-sized-rust https://github.com/johnthagen/min-size
by jamincan 4y ago
You can check out a number of strategies for reducing rust binary size here: https://github.com/johnthagen/min-sized-rust https://github.com/johnthagen/min-sized-rust
I don't think he mentions it, and I doubt it's relevant in your Hello World example, but if you have a lot of generic code, it's useful to extract the non-generic parts into a separate non-generic function. For example:
fn foo<T: AsRef<str>>(s: T) -> String {
bar(s.as_ref())
}
fn bar(s: &str) -> String {
// A whole bunch of other stuff
s.to_string()
}