GithubHelp home page GithubHelp logo

accessors's People

Contributors

emk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

accessors's Issues

Doc comments

  • Emit #[allow(missing_docs)] on the impl block.

  • Reuse doc comments on the fields for the corresponding getters and setters. The comments won't be exactly in the style that getters should have and even worse for setters, but it may be better than nothing. My getters macro does this.

  • You could also support overriding the doc comment with a field-level attribute like #[getter(doc = "Gets the foo.")] #[setter(doc = "Sets the foo.")]

Support overriding the return type of a getter for deref-coercible types

For example, to allow a getter for a foo: Foo field to return &Bar instead of &Foo. For example a #[getter(return = "&Bar")] field attribute. Of course this will only work for deref-coercible types since the body of the getter will still be &self.foo.


It might also be good to have some overrides like this as part of the base crate. For example, my own macro has overrides for String -> &str, Option<String> -> Option<&str>, Option<T> -> Option<&T>, Vec<String> -> Vec<&str>, etc.

compilation failed with latest rust

When I tried to compile 'simple.rs' the following error appeared:

error: setters is a derive mode
--> src\main.rs:7:1
|
7 | #[setters(into)]
| ^^^^^^^^^^^^^^^^

When I commented out '#[setters(into)]' string the other error appeared:

error[E0428]: a type named Simple has already been defined in this module
--> src\main.rs:8:1
|
6 | #[derive(getters, setters)]
| ------- previous definition of Simple here
7 | //#[setters(into)]
8 | / struct Simple {
9 | | field: String,
10 | | }
| |_^ Simple already defined

error[E0308]: mismatched types
--> src\main.rs:15:17
|
15 | s.set_field("there");
| ^^^^^^^ expected struct std::string::String, found reference
|
= note: expected type std::string::String
found type &'static str
= help: here are some functions which might fulfill your needs:
- .escape_debug()
- .escape_default()
- .escape_unicode()
- .to_lowercase()
- .to_uppercase()

error: aborting due to previous error(s)
accessors-test.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.