diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-12-09 15:55:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-09 15:55:05 +0100 |
commit | b1379b7de3045000c1f4fd76a503b4e639946348 (patch) | |
tree | 9a8629bb212669bcbbf16c2666697cee023210e9 | |
parent | f15b3d84a562f07581fd350488b2c22dff0ed528 (diff) |
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.
-rw-r--r-- | core/gotham_state.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/gotham_state.rs b/core/gotham_state.rs index dfa3b3ea7..e42664223 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::<MyStruct>().is_none()); assert!(state.try_borrow::<MyStruct>().is_none()); } + + #[test] + fn type_alias() { + let mut state = GothamState::default(); + state.put::<Alias1>("alias1".to_string()); + state.put::<Alias2>("alias2".to_string()); + assert_eq!(state.take::<Alias1>(), "alias2"); + assert!(state.try_take::<Alias1>().is_none()); + assert!(state.try_take::<Alias2>().is_none()); + } } |