Skip to content

Commit fd25394

Browse files
authored
Add draft chapter for Provider Delegation (#9)
* Initial draft for provider delegation chapter * More draft * Improve introduction * Finish drafting chapter for Provider Delegation
1 parent 06b1a06 commit fd25394

File tree

8 files changed

+786
-25
lines changed

8 files changed

+786
-25
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ edition = "2021"
55

66
[dependencies]
77
itertools = "0.13.0"
8-
serde = "1"
9-
serde_json = "1"
8+
serde = {version = "1", features = ["derive"] }
9+
serde_json = "1"
10+
anyhow = "1"

content/SUMMARY.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Summary
22

3-
[Introduction](introduction.md)
3+
- [Introduction](introduction.md)
44

55
# Core Concepts
66

@@ -14,9 +14,8 @@
1414
- [Impl-side Dependencies](impl-side-dependencies.md)
1515
- [Provider Traits](provider-traits.md)
1616
- [Linking Consumers with Providers](consumer-provider-link.md)
17-
- [Delegation](delegation.md)
18-
- [Component](component.md)
19-
- [Component Macros](component-macros.md)
17+
- [Provider Delegation](provider-delegation.md)
18+
- [Component Macros](component-macros.md)
2019
- [Check Traits](check-traits.md)
2120

2221
# Design Patterns

content/delegation.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

content/introduction.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
# Introduction
22

3-
This book covers the design patterns for _context-generic programming_ (CGP), a new programming paradigm for Rust.
4-
5-
At its core, context-generic programming allows us to write _modular_ code that are _generic_ over different _contexts_.
6-
Thoughout the book, we will slowly uncover what that really means.
3+
This book covers the design patterns for _context-generic programming_ (CGP),
4+
a new programming paradigm for Rust that allows strongly-typed components
5+
to be implemented and composed in a modular, generic, and type-safe way.
6+
7+
## What is Context-Generic Programming
8+
9+
At its core, CGP makes use of Rust's trait system to build generic _interfaces_
10+
decouple code that _consumes_ an interface from code that _implements_ an
11+
interface. Through this decoupling, code can be written to be generic over
12+
any context, and then be wired to be used on a concrete context by writing
13+
few lines of code. CGP makes use of Rust's strong type system to help ensure
14+
that any such wiring is _type-safe_, catching any unsatisfied dependencies
15+
as compile-time errors.
16+
17+
CGP shares some similarities with other modular programming patterns, such as
18+
OCaml modules, Scala implicits, mixins, and dependency injection. Compared to
19+
these other patterns, CGP has a unique advantage that it enables high modularity
20+
while also being type-safe and concise. With Rust as its host language, CGP
21+
also allows high-performance and low-level code to be written in a modular
22+
way, without requiring complex runtime support.
23+
24+
Thoughout this book, we will slowly understand how CGP works, and learn about
25+
useful design patterns that can be used in any programming situation.
726

827
## Work In Progress
928

0 commit comments

Comments
 (0)