You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-07-14 10:04:19 +02:00
Formatting.
This commit is contained in:
@ -26,15 +26,15 @@ Additional items speaker may mention:
|
||||
types. ["Domain Modeling Made Functional"][1] is a great resource on the
|
||||
topic, with examples written in F#.
|
||||
|
||||
- Despite Rust's functional roots, functional design patterns don't translate as-is
|
||||
to Rust. For instance, extensive use of higher-order functions and higher-kinded types can
|
||||
result in code that is harder to read and maintain. Design patterns in Rust
|
||||
must take into account (and leverage!) the granular control over mutability
|
||||
that comes with its borrow checker.
|
||||
- Despite Rust's functional roots, functional design patterns don't translate
|
||||
as-is to Rust. For instance, extensive use of higher-order functions and
|
||||
higher-kinded types can result in code that is harder to read and maintain.
|
||||
Design patterns in Rust must take into account (and leverage!) the granular
|
||||
control over mutability that comes with its borrow checker.
|
||||
|
||||
- The same caution should be applied to object-oriented design patterns. Rust
|
||||
doesn't support inheritance, and object decomposition should take into account the
|
||||
constraints introduced by the borrow checker.
|
||||
doesn't support inheritance, and object decomposition should take into account
|
||||
the constraints introduced by the borrow checker.
|
||||
|
||||
- Mention that type-level programming can be often used to create "zero-cost
|
||||
abstractions", although the label can be misleading: the impact on compile
|
||||
|
@ -4,7 +4,8 @@ minutes: 5
|
||||
|
||||
# Semantic Confusion
|
||||
|
||||
When a function takes multiple arguments of the same type, call sites are unclear:
|
||||
When a function takes multiple arguments of the same type, call sites are
|
||||
unclear:
|
||||
|
||||
```rust
|
||||
# struct LoginError;
|
||||
@ -49,7 +50,8 @@ login(password, username);
|
||||
|
||||
- Nonetheless, note that there are legitimate scenarios where a function may
|
||||
take multiple arguments of the same type. In those scenarios, if correctness
|
||||
is of paramount importance, consider using a struct with named fields as input:
|
||||
is of paramount importance, consider using a struct with named fields as
|
||||
input:
|
||||
```rust
|
||||
pub struct LoginArguments {
|
||||
pub username: &str,
|
||||
|
Reference in New Issue
Block a user