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

Incorrect text in Command pattern description #346

Open
izderadicka opened this issue Feb 18, 2023 · 0 comments
Open

Incorrect text in Command pattern description #346

izderadicka opened this issue Feb 18, 2023 · 0 comments
Labels
A-pattern Area: Content about Patterns C-amendment Category: Amendments to existing content good first issue Good for newcomers

Comments

@izderadicka
Copy link

Since function pointers implement all three traits Fn, FnMut, and FnOnce we could as well pass and store closures instead of function pointers.

This is not exactly correct function pointers can be created only from non-capturing closures. Which can be easily verified if you change example little bit:

error[[E0308]](https://doc.rust-lang.org/stable/error_codes/E0308.html): mismatched types
  --> src/main.rs:41:26
   |
41 |     schema.add_migration(|| format!("create {}",table), || "drop table".to_string());
   |            ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found closure
   |            |
   |            arguments to this function are incorrect
   |
   = note: expected fn pointer `fn() -> String`
                 found closure `[closure@src/main.rs:41:26: 41:28]`
note: closures can only be coerced to `fn` types if they do not capture any variables

@simonsan simonsan added good first issue Good for newcomers A-pattern Area: Content about Patterns C-amendment Category: Amendments to existing content labels Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pattern Area: Content about Patterns C-amendment Category: Amendments to existing content good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants