ros2_rust icon indicating copy to clipboard operation
ros2_rust copied to clipboard

Add support for constants in messages

Open nnmm opened this issue 3 years ago • 2 comments

Currently, constants (such as string MY_CONSTANT_STRING="ros2_rust") are not supported yet by rosidl_generator_rs. It would be nice to support them, for feature parity with other languages.

Should they be const or static on the Rust side?

nnmm avatar Apr 28 '22 19:04 nnmm

Should they be const or static on the Rust side?

Is there any reason, why they should be static instead of const?

Nizerlak avatar Jul 27 '22 19:07 Nizerlak

Should they be const or static on the Rust side?

Is there any reason, why they should be static instead of const?

Some of the constants have types that cannot be constructed as a const, e.g. string types, but with a static we could use the lazy initialization workaround (e. g. using https://crates.io/crates/once_cell).

nnmm avatar Jul 27 '22 19:07 nnmm

Done in https://github.com/ros2-rust/ros2_rust/pull/269

nnmm avatar Oct 06 '22 13:10 nnmm