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