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

Tiny doc improvement: prefer let mut item: ActiveModel = Default::default(); #1042

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

greyblake
Copy link

Hi, thanks for the work you do!

I was reading through the docs, and noticed that one thing can be slightly shorten.
Instead of

    let mut item = ActiveModel {
        ..Default::default()
    };

One could write

let mut item: ActiveModel = Default::default();

The PR also fixes indentation in the add function (4 spaces instead of 2 spaces).

@@ -586,7 +584,7 @@ pub fn routes() -> Routes {
.add("/", post(add))
.add("/:id", get(get_one))
.add("/:id", delete(remove))
.add("/:id", post(update))
.add("/:id", patch(update))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scaffold with --api option also uses patch for update.

@jondot
Copy link
Contributor

jondot commented Dec 1, 2024

Thanks, the reason we use the "spread" variant is that often you want to actually plug a few values right there, and so it is more convenient that we use this.
However I cannot create a convincing argument enough :)

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