Rust Programming Builder patterns tutorial and constructors patterns as well. We will also outline the pros & cons between the non-consuming and consuming builder pattern.
Help support this channel: / jeremychone
Chapters:
00:00 - Intro
00:28 - Constructor Patterns
04:37 - Builder Patterns
GitHub link: https://github.com/jeremychone-channe...
Bonus in the GitHub repo - State Builder Pattern (Video in the work) - https://github.com/jeremychone-channe...
Notes:
1) Struct literals and simple constructor functions are great ways to create structs and enums.
2) Builder pattern are useful when building the more complex data structure, especially when step building is required.
3) non-consuming-builder-pattern prop...(&mut self) and build(&self), can be considered more ergonomic, but would require unnecessary allocations when the object built needs to own the data passed to the builder.
4) non-consuming-builder-pattern with mutable build (i.e. build(&mut self) ) could be considered a bad pattern, as calling build() twice will give different result (except in the 6) case).
5) The consuming-builder-pattern requires reassigning the builder for each "builder chain command" and cloning if the builder needs to be reused. But it allows to avoid uncessary allocations.
6) In some situation, where the object built does not take any value from the builder, the non-consuming-builder-pattern might be appropriate.
7) Personally, other than 6), I find the Consuming-builder-pattern better aligned with the compiler ownership rules. New allocations become explicit by requiring clone, and the builder cannot be reused without explicit clone.
8) However, study the pros & cons of each pattern, and use what makes sense to you and your team for your given use-cases.
9) The "impl Into String " pattern is not related to constructor or builder patterns but can be used with any function. Use this pattern if you find it productive and relevant to your use case. This previous video: • Rust Tip - Into String as Function Ar...
How I start my new project: • Rust - Simple Code Layout (start simp...
Reddit discussion about this video: / rust_builder_pattern_tutorial_constructors
Other Resources:
Great state builder [attern article: https://www.greyblake.com/blog/builde... (eventually I will do a video on the state builder pattern)
Jeremy Chone:
Twitter - / jeremychone
Discord On Rust - / discord
AWESOME-APP - https://awesomeapp.dev - Rust Templates for building awesome applications.
Patreon - / jeremychone - Any help is a big help (for Rust educational content)
Feeback welcome, happy coding!
Other popular Rust Programming videos:
Quick Start Code Layout - • Rust - Simple Code Layout (start simp...
AWESOME-APP Full Overview - Rust template for building Awesome Desktop Application: • Building Awesome Desktop App with Rus...
Tauri Quick Introduction (Desktop App wit Rust Programming): • Rust Tauri 1.0 - Quick Intro - Rust D...
Rust Web App tutorials series: • Rust Web App - 1/3 - Data Access
Rust Bevy Full Tutorial - Game Development with Rust: • Rust Bevy Full Tutorial - Game Develo...
Rust for Java Developers series: • Rust for Java Developers 1/3 - Introd...
Playlists:
Rust For Desktop App: • JC - Rust Programming for Desktop App
Everything Rust Programming - Tutorials, Courses, Tips, Examples: • JC - Rust - Everything Rust Programmi...
Rust Programming for Web Development: • JC - Rust Programming for Web Develop...
Rust Courses: • Rust Course 2021 by the book | RustLang
Furst for Java Developers: • Rust for Java Developers
AWESOME-APP ➜ https://awesomeapp.dev - Rust Templates for building awesome applications.
Rust AWESOME-APP GitHub - https://github.com/orgs/rust-awesome-...
Other notes:
Tool used to do the green lines. ScreenBrush on Mac App Store (Gromit seems to be the equivalent on Linux)
Edited with Davinci Resolve.
Auf dieser Seite können Sie das Online-Video Rust Programming: The Ultimate Builder Pattern Tutorial mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Jeremy Chone 04 Dezember 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 39,889 Mal angesehen und es wurde von 1.7 tausend den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!