Skip to content

Commit 5148cd2

Browse files
authored
Update CGP version to v0.2 (#14)
1 parent 2e2c2dc commit 5148cd2

File tree

5 files changed

+106
-41
lines changed

5 files changed

+106
-41
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ itertools = "0.11.0"
88
serde = {version = "1", features = ["derive"] }
99
serde_json = "1"
1010
anyhow = "1"
11-
cgp = { version = "0.1.0" }
11+
cgp = { version = "0.2.0" }

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
This repository contains the source code for the book _Context-Generic Programming Patterns_. The published version of this book is available at https://patterns.contextgeneric.dev/.
88

9+
For more information about context-generic programming, check out the
10+
main website at https://www.contextgeneric.dev/.
11+
912
## Build Instructions
1013

1114
This book is built using [mdBook](https://rust-lang.github.io/mdBook/). Follow the [installation instructions](https://rust-lang.github.io/mdBook/guide/installation.html) to install mdBook on your machine. You can then serve a local version of the book by running:

content/component-macros.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,20 @@ use serde::{Serialize, Deserialize};
189189

190190
// Component definitions
191191

192-
#[derive_component(StringFormatterComponent, StringFormatter<Context>)]
192+
#[cgp_component {
193+
name: StringFormatterComponent,
194+
provider: StringFormatter,
195+
context: Context,
196+
}]
193197
pub trait CanFormatToString {
194198
fn format_to_string(&self) -> Result<String, Error>;
195199
}
196200

197-
#[derive_component(StringParserComponent, StringParser<Context>)]
201+
#[cgp_component {
202+
name: StringParserComponent,
203+
provider: StringParser,
204+
context: Context,
205+
}]
198206
pub trait CanParseFromString: Sized {
199207
fn parse_from_string(raw: &str) -> Result<Self, Error>;
200208
}

content/debugging-techniques.md

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,20 @@ Consider if we made a mistake and forgot to implement `Serialize` for `Person`:
3535
# use anyhow::Error;
3636
# use serde::{Serialize, Deserialize};
3737
#
38-
# #[derive_component(StringFormatterComponent, StringFormatter<Context>)]
38+
# #[cgp_component {
39+
# name: StringFormatterComponent,
40+
# provider: StringFormatter,
41+
# context: Context,
42+
# }]
3943
# pub trait CanFormatToString {
4044
# fn format_to_string(&self) -> Result<String, Error>;
4145
# }
4246
#
43-
# #[derive_component(StringParserComponent, StringParser<Context>)]
47+
# #[cgp_component {
48+
# name: StringParserComponent,
49+
# provider: StringParser,
50+
# context: Context,
51+
# }]
4452
# pub trait CanParseFromString: Sized {
4553
# fn parse_from_string(raw: &str) -> Result<Self, Error>;
4654
# }
@@ -108,12 +116,20 @@ call `format_to_string`, and check if it works:
108116
# use anyhow::Error;
109117
# use serde::{Serialize, Deserialize};
110118
#
111-
# #[derive_component(StringFormatterComponent, StringFormatter<Context>)]
119+
# #[cgp_component {
120+
# name: StringFormatterComponent,
121+
# provider: StringFormatter,
122+
# context: Context,
123+
# }]
112124
# pub trait CanFormatToString {
113125
# fn format_to_string(&self) -> Result<String, Error>;
114126
# }
115127
#
116-
# #[derive_component(StringParserComponent, StringParser<Context>)]
128+
# #[cgp_component {
129+
# name: StringParserComponent,
130+
# provider: StringParser,
131+
# context: Context,
132+
# }]
117133
# pub trait CanParseFromString: Sized {
118134
# fn parse_from_string(raw: &str) -> Result<Self, Error>;
119135
# }
@@ -246,12 +262,20 @@ defined as follows:
246262
# use anyhow::Error;
247263
# use serde::{Serialize, Deserialize};
248264
#
249-
# #[derive_component(StringFormatterComponent, StringFormatter<Context>)]
265+
# #[cgp_component {
266+
# name: StringFormatterComponent,
267+
# provider: StringFormatter,
268+
# context: Context,
269+
# }]
250270
# pub trait CanFormatToString {
251271
# fn format_to_string(&self) -> Result<String, Error>;
252272
# }
253273
#
254-
# #[derive_component(StringParserComponent, StringParser<Context>)]
274+
# #[cgp_component {
275+
# name: StringParserComponent,
276+
# provider: StringParser,
277+
# context: Context,
278+
# }]
255279
# pub trait CanParseFromString: Sized {
256280
# fn parse_from_string(raw: &str) -> Result<Self, Error>;
257281
# }
@@ -372,12 +396,20 @@ the super trait of `CanUsePerson` as follows:
372396
# use anyhow::Error;
373397
# use serde::{Serialize, Deserialize};
374398
#
375-
# #[derive_component(StringFormatterComponent, StringFormatter<Context>)]
399+
# #[cgp_component {
400+
# name: StringFormatterComponent,
401+
# provider: StringFormatter,
402+
# context: Context,
403+
# }]
376404
# pub trait CanFormatToString {
377405
# fn format_to_string(&self) -> Result<String, Error>;
378406
# }
379407
#
380-
# #[derive_component(StringParserComponent, StringParser<Context>)]
408+
# #[cgp_component {
409+
# name: StringParserComponent,
410+
# provider: StringParser,
411+
# context: Context,
412+
# }]
381413
# pub trait CanParseFromString: Sized {
382414
# fn parse_from_string(raw: &str) -> Result<Self, Error>;
383415
# }

0 commit comments

Comments
 (0)