2022-12-16
2145
#rust
Andre Bogus
148572
104
Dec 16, 2022 â‹… 7 min read

How to build a Rust API with the builder pattern

Andre Bogus Andre "llogiq" Bogus is a Rust contributor and Clippy maintainer. A musician-turned-programmer, he has worked in many fields, from voice acting and teaching, to programming and managing software projects. He enjoys learning new things and telling others about them.

Recent posts:

Creating toast notifications using Solid Toast

Toast notifications are messages that appear on the screen to provide feedback to users. When users interact with the user […]

Chimezie Innocent
Sep 6, 2024 â‹… 7 min read
Deno Adoption Guide: Overview, Examples, And Alternatives

Deno adoption guide: Overview, examples, and alternatives

Deno’s features and built-in TypeScript support make it appealing for developers seeking a secure and streamlined development experience.

Emmanuel Odioko
Sep 5, 2024 â‹… 10 min read
Types vs. Interfaces in TypeScript

Types vs. interfaces in TypeScript

It can be difficult to choose between types and interfaces in TypeScript, but in this post, you’ll learn which to use in specific use cases.

Yan Sun
Sep 5, 2024 â‹… 9 min read
Flutter Logo

How to build a bottom navigation bar in Flutter

This tutorial demonstrates how to build, integrate, and customize a bottom navigation bar in a Flutter app.

Pinkesh Darji
Sep 5, 2024 â‹… 6 min read
View all posts

2 Replies to "How to build a Rust API with the builder pattern"

  1. The build patterns are awkward because of the borrow checker, the complexity is obvious from articles like this. So my conclusion is actually that optional named parameters are very much needed in Rust to alleviate the creation of objects with a less heavy solution that is more efficient, easier to read and that doesn’t require the creation of intermediate objects.

    Another alternative is to make functions and methods optionally pass ownership, only if the function/method output is assigned to a variable.

  2. I disagree. First, often you can get away with having one or two methods or a plain struct to work with. The builder just ensures a nice and flexible interface while keeping open the door to later changes. Also the complexity cost is mostly paid by libraries which are usually meant to be reused, thus amortizing the investment.

Leave a Reply