2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(unused_variables)]
|
2016-08-29 14:53:18 -05:00
|
|
|
use std::ops::Deref;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
if env_var("FOOBAR").as_ref().map(Deref::deref).ok() == Some("yes") {
|
|
|
|
panic!()
|
|
|
|
}
|
|
|
|
|
|
|
|
let env_home: Result<String, ()> = Ok("foo-bar-baz".to_string());
|
|
|
|
let env_home = env_home.as_ref().map(Deref::deref).ok();
|
|
|
|
|
|
|
|
if env_home == Some("") { panic!() }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[inline(never)]
|
|
|
|
fn env_var(s: &str) -> Result<String, VarError> {
|
|
|
|
Err(VarError::NotPresent)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub enum VarError {
|
|
|
|
NotPresent,
|
|
|
|
NotUnicode(String),
|
|
|
|
}
|