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

Some suggestion #4

Closed
chmnchiang opened this issue Nov 29, 2017 · 3 comments
Closed

Some suggestion #4

chmnchiang opened this issue Nov 29, 2017 · 3 comments

Comments

@chmnchiang
Copy link

  1. Aren't Crossbeam and Rayon libraries about threads? They doesn't seem to match the description "Run external commands".

  2. The python code of derive_new crate __init__(self, value='default') kind of suggest that rust has optional parameters, which rust does not.

@rochacbruno
Copy link
Owner

  1. I'll dig more into Crossbeam and Rayon and also try to find the external command runner equivalent, thanks

  2. about derive_new, it offers default values for initializers just like in Python's __init__ method.

use std::marker::PhantomData;

#[derive(new)]
struct Generic<'a, T: Default, P> {
    x: &'a str,
    y: PhantomData<P>,
    #[new(default)]
    z: T,
}

let _ = Generic::<i32, u8>::new("Hello");

If you have suggestion to replace Rayon and Crossbeam on the list or better description to derive_new please send a Pull Request!

rochacbruno added a commit that referenced this issue Nov 29, 2017
@rochacbruno
Copy link
Owner

1 is fixed!

@chmnchiang
Copy link
Author

For 2. I meant someone might though

#[derive(new)]
struct Foo {
    #[new(value = "default")]
    value: String,
}

Foo::new();
Foo::new("bar");

would work, since python supports optional argument.

It's not a big problem at all, just a small suggestion.
So I think it's up to you, who is the owner of this awesome list, to decide whether to change it or not.

Repository owner deleted a comment Nov 29, 2017
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

No branches or pull requests

2 participants