Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic arguments #8

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

danieleades
Copy link

fixes #7
I've made most of the functions generic over the input they actually need, rather than concrete types. I think there's still some work to be done to improve the api.

this is a minor breaking change as seen below-

before

fn example(s: String) {
   let x: String = s;
}

fn main() {
   let my_str : &'static str = "example string";

  // this won't compile after the change as type ascriptions would be required to determine how to apply 'into()'
   example(my_str.into())
}

after

fn example<S: Into<String>>(s: S) {
   let x: String = s.into();
}

fn main() {
   let my_str : &'static str = "example string";

  // consumer of library can now use any type which can be converted into a concrete string to call the function
   example(my_str)
}

@OtaK OtaK self-requested a review January 3, 2019 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants