Created
August 4, 2016 13:29
-
-
Save killercup/23b98645fa7fd68cb9e28da9425a62f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unused_variables)] | |
// A bit more typing for the API author. | |
// (Sadly, the parameters need to be specified individually – or Rust would | |
// infer the concrete type from the first parameter given. This reads not as | |
// nicely, and documentation might not look as pretty as before.) | |
fn foo<I, D, S>(lorem: &str, ipsum: I, dolor: D, sit: S) where | |
I: Into<Option<i32>>, | |
D: Into<Option<i32>>, | |
S: Into<Option<i32>>, | |
{ | |
println!("{}", lorem); | |
} | |
fn main() { | |
foo("bar", None, None, None); // Still weird | |
foo("bar", 42, None, None); // Okay | |
foo("bar", 42, 1337, -1); // Wow, that's nice! Gimme more APIs like this! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment