Ownership issue with a static HashMap

The lock().unwrap() gives you a MutexGuard, which limits the lifetime of anything you access through it. This will be just a temporary value dropped at the end of your expression, which doesn't let the value from get survive. Try storing that guard in a local first.