I'm trying to create static or constant from matching the env::home_dir:
static home: String = match env::home_dir() {
Some(ref p) => p.to_str().unwrap().to_owned(),
None => "./".to_string(),
};
But I'm getting a compiler bug:
src/main.rs:15:8: 15:13 error: internal compiler error: no enclosing scope found for scope: CodeExtent(346/Misc(20))
src/main.rs:15 Some(ref p) => p.to_str().unwrap().to_owned(),
^~~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', ../src/libsyntax/diagnostic.rs:175
Is this a bug in my code or I should report this bug? Is it possible to get home as constant or static value?
I need to use it multiple times to add some file names for some file operations and I want to have them all in same folder.