Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Guard;
- impl Drop for Guard {
- fn drop(&mut self) {
- println!("Dropped");
- }
- }
- impl Guard {
- pub fn get(&self) -> Option<bool> {
- Some(true)
- }
- pub fn get_none(&self) -> Option<bool> {
- None
- }
- }
- fn main() {
- if let Some(_) = Guard.get() {
- println!("Inside IF 1");
- }
- println!("------------");
- if let Some(_) = { Guard.get() } {
- println!("Inside IF 2");
- }
- println!("------------");
- match { Guard.get() } {
- Some(_) => { println!("Inside Match"); }
- _ => ()
- }
- println!("------------");
- if Guard.get().is_some() {
- println!("Inside IF 4");
- }
- println!("------------");
- let x = { Guard.get() };
- if let Some(_) = x {
- println!("Inside IF 5");
- }
- println!("------------");
- if let Some(_) = Guard.get_none() {
- println!("Inside IF 6 in then, never go there");
- } else {
- println!("Inside IF 6 in else");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement