#derive #telebot #getters

macro telebot-derive

Getters and setters for the telebot library

12 releases

new 0.0.13 Jun 12, 2019
0.0.12 Sep 11, 2018
0.0.11 Apr 9, 2018
0.0.10 Jan 5, 2018
0.0.2 Dec 31, 2016
Download history 32/week @ 2019-02-27 32/week @ 2019-03-06 5/week @ 2019-03-13 79/week @ 2019-03-20 28/week @ 2019-03-27 15/week @ 2019-04-03 6/week @ 2019-04-10 5/week @ 2019-04-17 34/week @ 2019-04-24 7/week @ 2019-05-01 16/week @ 2019-05-08 37/week @ 2019-05-15 28/week @ 2019-05-22 7/week @ 2019-05-29 22/week @ 2019-06-05

96 downloads per month
Used in 5 crates (1 directly)

MIT license

17KB
304 lines

#[derive(accessors)]: getters and setters for Rust (WIP)

This is a work in progress! The API is subject to change.

We use the new macros 1.1 support in nightly Rust to automatically generate basic getters and setters. This is useful if you have a library that exports a struct with lots of fields, but you don't want to make the fields themselves public.

If you specify #[setters(into)], you can generate setters which use Into to automatically convert to the desired type.

#![feature(proc_macro)]

#[macro_use]
extern crate accessors;

#[derive(getters, setters)]
#[setters(into)]
struct Simple {
    field: String,
}

fn main() {
    let mut s = Simple { field: "hello".to_owned() };
    println!("{}", s.field());
    s.set_field("there");
}

Right now, you can only use this with nightly Rust, but David Tolnay has laid out a roadmap for how to get it working with stable Rust.

Dependencies

~1MB
~24K SLoC