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:

Comparing Hattip Vs Express Js For Modern Application Development

Comparing Hattip vs. Express.js for modern app development

Explore what Hattip is, how it works, its benefits and key features, and the differences between Hattip and Express.js.

Antonello Zanini
May 2, 2024 â‹… 8 min read
Using React Shepherd To Build A Site Tour

Using React Shepherd to build a site tour

React Shepherd stands out as a site tour library due to its elegant UI and out-of-the-box, easy-to-use React Context implementation.

Onuorah Bonaventure
May 1, 2024 â‹… 14 min read
A Guide To Cookies In Next Js

A guide to cookies in Next.js

Cookies are crucial to web development. This article will explore how to handle cookies in your Next.js applications.

Georgey V B
Apr 30, 2024 â‹… 10 min read
Handling Dates In JavaScript With Tempo

Handling dates in JavaScript with Tempo

Use the Tempo library to format dates and times in JavaScript while accounting for time zones, daylight saying time, and date internationalization.

Amazing Enyichi Agu
Apr 30, 2024 â‹… 8 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