Skip to content

Commit

Permalink
README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hanepjiv committed Dec 4, 2024
1 parent 9831ac3 commit 11af215
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pub(crate) mod mine {
#[elicit_define(mine_elicit)]
pub(crate) trait Mine {
fn action(&self) -> i32;
fn action_mut(&mut self) -> i32;
fn action(&self) -> i32;
fn action_mut(&mut self) -> i32;
}
// pub(crate) mine_elicit::author as elicit_author;
Expand All @@ -26,40 +26,40 @@ pub(crate) mod mine {
pub(crate) struct X {}
impl Mine for X {
fn action(&self) -> i32 {
0i32
}
fn action_mut(&mut self) -> i32 {
0i32
}
fn action(&self) -> i32 {
0i32
}
fn action_mut(&mut self) -> i32 {
0i32
}
}
#[derive(Debug, Clone, Elicit)]
#[elicit_mod_author(mine_elicit::author)]
// #[elicit_from_self_field(_fsf)] // here
pub(crate) struct Y {
#[elicit_from_self_field] // or here
_fsf: mine_elicit::author::ElicitFromSelfField,
i: i32,
#[elicit_from_self_field] // or here
_fsf: mine_elicit::author::ElicitFromSelfField,
i: i32,
}
impl Y {
pub(crate) fn new(a: i32) -> Self {
Y {
_fsf: Default::default(),
i: a,
}
pub(crate) fn new(a: i32) -> Self {
Y {
_fsf: Default::default(),
i: a,
}
}
}
impl Mine for Y {
fn action(&self) -> i32 {
self.i
}
fn action_mut(&mut self) -> i32 {
self.i += 1;
self.i
}
fn action(&self) -> i32 {
self.i
}
fn action_mut(&mut self) -> i32 {
self.i += 1;
self.i
}
}
}
Expand All @@ -72,18 +72,18 @@ pub(crate) fn fire() -> elicit::Result<()> {
e = MineElicit::new(X::default())?;
e.try_with(|m| -> elicit::Result<()> {
println!("{:?}", m);
assert!(m.action() == 0);
Ok(())
println!("{:?}", m);
assert!(m.action() == 0);
Ok(())
})?;
let y = Y::new(1);
e = MineElicit::new(y)?;
e.try_with_mut(|m| -> elicit::Result<()> {
println!("{:?}", m);
assert!(m.action_mut() == 2);
Ok(())
println!("{:?}", m);
assert!(m.action_mut() == 2);
Ok(())
})?;
Ok(())
Expand All @@ -97,9 +97,9 @@ fire().expect("Doc-tests");
Licensed under either of

* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
(<http://www.apache.org/licenses/LICENSE-2.0>)
* MIT license
([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
(<http://opensource.org/licenses/MIT>)

at your option.

Expand Down

0 comments on commit 11af215

Please sign in to comment.