Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. macro_rules! some_if{
  2. ($condition:expr,$some:expr) ==> {{
  3. match $condition{
  4. true => Some($some),
  5. _ => None,
  6. }
  7. }}
  8. }
  9.  
  10. #[test]
  11. fn test_it_works(){
  12. let maybe= some_if!(true,"aha");
  13. match maybe{
  14. Ok(s)=> assert!(s.eq("aha")),
  15. _ => assert!(false,"uuh")
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement