SHARE
TWEET

Untitled

a guest Aug 20th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fn some_operation_ver1(param1: Option<&i32>) {
  2.     let _x: Option<&i32> = param1;
  3. }
  4.  
  5. fn some_operation_ver2<'a, T1: Into<Option<&'a i32>>>(param1: T1) {
  6.     let _x: Option<&i32> = Into::into(param1);
  7. }
  8.  
  9.  
  10. fn main() {
  11.     // Clean version
  12.     some_operation_ver1(Some(&32)); // Must use Some
  13.    
  14.     // Complex version
  15.     some_operation_ver2(Some(&32)); // Can use Some
  16.     some_operation_ver2(&32); // Can also not use it
  17. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top