Implement `Default` for `fn` types and closures.
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 6.6k
- Forks
- 1.7k
- Avg merge
- 16h 14m
- Merged PRs (30d)
- 1
Description
I could avoid some unsafe code if the types of functions and closures-without-captures implemented the Default trait.
Theoretically you could extend this to closures that only capture things implementing Default, but starting with only closures that have no captures seems like a safer bet, and it can always be extended later.
Example:
fn call_by_type<F: Fn() + Copy + Default>() {
let f = F::default();
f();
}
fn wrapper<F: Fn() + Copy + Default>(_f: F) {
call_by_type::<F>();
}
fn foo() {
println!("Hello, world!");
}
fn main() {
wrapper(foo);
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's closure and function-pointer example, then review the Rust RFC process in this repository to determine the required proposal and design work. The scope currently covers captureless closures and function types, with captured closures left as a possible later extension; done means a settled design and an accepted or rejected RFC outcome.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100