sofa
sofa copied to clipboard
Generic arguments
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)
}