Skip to content

Commit 668366d

Browse files
committed
rename
1 parent 37869ef commit 668366d

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

examples/enum_keypath_example.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ enum SomeOtherStatus {
2020

2121
fn main() {
2222
// ---------- EnumPath ----------
23-
let cp = KeyPaths::prism(Status::Active, |u| match u {
23+
let cp = KeyPaths::readable_enum(Status::Active, |u| match u {
2424
Status::Active(e) => Some(e),
2525
_ => None,
2626
});
2727
// let cp2 = enum_keypath!(Status::Inactive(()));
28-
let cp2 = KeyPaths::prism(Status::Inactive, |u| match u {
28+
let cp2 = KeyPaths::readable_enum(Status::Inactive, |u| match u {
2929
Status::Inactive(e) => None,
3030
_ => None,
3131
});
3232

3333
// let cp3 = enum_keypath!(SomeOtherStatus::Active(String));
34-
let cp3 = KeyPaths::prism(SomeOtherStatus::Active, |u| match u {
34+
let cp3 = KeyPaths::readable_enum(SomeOtherStatus::Active, |u| match u {
3535
SomeOtherStatus::Active(e) => Some(e),
3636
_ => None,
3737
});
@@ -40,7 +40,7 @@ fn main() {
4040
}
4141

4242
// let cp4 = enum_keypath!(SomeOtherStatus::Inactive);
43-
let cp4 = KeyPaths::prism(|u: ()| { SomeOtherStatus::Inactive }, |u| None);
43+
let cp4 = KeyPaths::readable_enum(|u: ()| { SomeOtherStatus::Inactive }, |u| None);
4444
if let Some(x) = cp4.get(&SomeOtherStatus::Inactive) {
4545
println!("Inactive: {:?}", x);
4646
}

examples/prism.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::rc::Rc;
21
use key_paths_core::KeyPaths;
32

43
#[derive(Debug)]
@@ -18,7 +17,7 @@ fn main() {
1817
// // embed: Rc::new(|v| Payment::Cash { amount: v }),
1918
// embed: Rc::new(|v| Payment::Cash { amount: v.clone() }),
2019
// };
21-
let kp = KeyPaths::prism_mut(
20+
let kp = KeyPaths::writable_enum(
2221
|v| Payment::Cash { amount: v },
2322
|p: &Payment| match p {
2423
Payment::Cash { amount } => Some(amount),

examples/prism_compose.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn main() {
4747
let color_kp: KeyPaths<ABox, Color> = KeyPaths::failable_writable(|x: &mut ABox| Some(&mut x.color));
4848

4949

50-
let case_path = KeyPaths::prism_mut(
50+
let case_path = KeyPaths::writable_enum(
5151
{
5252
|v| Color::Other(v)
5353
},
@@ -67,6 +67,14 @@ fn main() {
6767
println!("{:?}", a_box);
6868
let color_rgb_kp = color_kp.compose(case_path);
6969
if let Some(value) = color_rgb_kp.get_mut(&mut a_box) {
70-
*value = RGBU8(10, 20, 30);
70+
*value = RGBU8(0, 0, 0);
7171
}
72-
}
72+
73+
println!("{:?}", a_box);
74+
75+
}
76+
77+
/*
78+
ABox { name: "A box", size: Size { width: 10, height: 20 }, color: Other(RGBU8(10, 20, 30)) }
79+
ABox { name: "A box", size: Size { width: 10, height: 20 }, color: Other(RGBU8(0, 0, 0)) }
80+
*/

0 commit comments

Comments
 (0)