File: self_builder.rs

package info (click to toggle)
rust-buildstructor 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 532 kB
  • sloc: makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,254 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use buildstructor::buildstructor;

#[derive(Default)]
pub struct Client;

#[buildstructor]
impl Client {
    #[builder(entry = "message", exit = "send")]
    fn call_with_no_return(self, _simple: String) {}

    #[builder(entry = "message_ref", exit = "send")]
    fn call_with_no_return_ref(&self, _simple: String) {}

    #[builder(entry = "message_ref_mut", exit = "send")]
    fn call_with_no_return_ref_mut(&mut self, _simple: String) {}

    #[builder(entry = "query", exit = "call")]
    fn call_with_return(self, _simple: String) -> bool {
        true
    }

    #[builder(entry = "query_ref", exit = "call")]
    fn call_with_return_ref(&self, _simple: String) -> bool {
        true
    }

    #[builder(entry = "query_ref_mut", exit = "call")]
    fn call_with_return_ref_mut(&mut self, _simple: String) -> bool {
        true
    }
}

fn main() {
    Client.message().simple("3".to_string()).send();
    Client.query().simple("3".to_string()).call();

    let client = Client;
    client.message_ref().simple("3".to_string()).send();
    client.query_ref().simple("3".to_string()).call();

    let mut client = Client;
    client.message_ref_mut().simple("3".to_string()).send();
    client.query_ref_mut().simple("3".to_string()).call();
}