Rust constants in different modules? -


i have "main.rs" file declare version constant.

pub const version: &'static str = "v2"; mod game; fn main() {    do_stuff(); } 

then want access global constant in different module "game.rs":

pub fn do_stuff() {    println!("this version: {}", version); } 

how make constant available everywhere?

as version declared in main.rs, crate root, can access using absolute path: ::version.

this should work:

pub fn do_stuff() {     println!("this version: {}", ::version); } 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -