Avatar

Peter F.

zshift@hachyderm.io
Joined
0 posts ā€¢ 6 comments

Formerly @z_shift on šŸ¦

Direct message

@Jenztsch @FizzyOrange

Eg

fn foo() -\> Vec\<i32\> {  
 let mut out = Vec::new();  
 macro! bar(i: i32) {  
 out.push(i);  
 }

 for i in 1..10 {  
 bar!(i);  
 }

 out  
}  
permalink
report
parent
reply

@Jenztsch @FizzyOrange it would be nice if rust had a feature like inline macros for this kind of behavior just for reducing duplications when you donā€™t need to capture values as part of a closure.

permalink
report
parent
reply

@varsock If you plan to refactor the architecture to convert things into microservices, grpc is also a solid way to go.

permalink
report
parent
reply

@varsock rust has very good code generation for C (and sometimes C++ as well) headers via bindgen (https://github.com/rust-lang/rust-bindgen). This allows you to potentially make minimal changes to the code without having to refactor to use a new protocol on the legacy side, and has faster performance (benchmark to confirm), since thereā€™s no serialization/deserialization step. See https://doc.rust-lang.org/nomicon/ffi.html for how this is done manually.

permalink
report
parent
reply

@varsock @Timely_Jellyfish_2077 out of curiosity, why use grpc in lieu of ffi?

permalink
report
parent
reply

@darkregn Checkout @jonhooā€™s channel. He has many videos doing deep dives into how rust works, and several case studies of existing crates and how they work. They are excellent resources for learning rust.

https://youtube.com/@jonhoo

permalink
report
reply