From b1379b7de3045000c1f4fd76a503b4e639946348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 9 Dec 2020 15:55:05 +0100 Subject: [PATCH] test(core): type aliases in OpState (#8653) This commit adds a test case to core/gotham_state.rs that shows that type aliases can't be used reliably. Instead wrapper types should be used. --- core/gotham_state.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/gotham_state.rs b/core/gotham_state.rs index dfa3b3ea7c..e426642238 100644 --- a/core/gotham_state.rs +++ b/core/gotham_state.rs @@ -94,6 +94,9 @@ mod tests { value: &'static str, } + type Alias1 = String; + type Alias2 = String; + #[test] fn put_borrow1() { let mut state = GothamState::default(); @@ -165,4 +168,14 @@ mod tests { assert!(state.try_borrow_mut::().is_none()); assert!(state.try_borrow::().is_none()); } + + #[test] + fn type_alias() { + let mut state = GothamState::default(); + state.put::("alias1".to_string()); + state.put::("alias2".to_string()); + assert_eq!(state.take::(), "alias2"); + assert!(state.try_take::().is_none()); + assert!(state.try_take::().is_none()); + } }