Code Monkey home page Code Monkey logo

strong-type's People

Contributors

yunjhongwu avatar

Stargazers

 avatar

Watchers

 avatar  avatar

strong-type's Issues

StrongType constructor not accessible from external module

Hi Yun-Jhong Wu,

Thanks for the crate StrongType, This is a great one.
Sorry if the issue I have is not very well explained, I am a newbie to rust.

I have external file, say timestamp.rs, where I define a strong type:
#[derive(StrongType)]
#[strong_type(auto_operators)]
pub struct Timestamp(usize);

When using in the main.rs an expression such as:

Timestamp(123456789) + Timestamp(987654321)

I get an error in the main.rs:

  • cannot initialize a tuple struct which contains private fields [...]
  • timestamp.rs(8, 20): constructor is not visible here due to private fields
  • timestamp.rs(8, 20): consider making the field publicly accessible: pub

If in timestamp.rs I do add pub in the declaration,

#[derive(StrongType)]
#[strong_type(auto_operators)]
pub struct NbTeams(pub usize);

I get another error, in the timestamp.rs:

  • proc-macro derive panicked
  • message: Strong type must be a tuple struct with one private field.

There might be some proper way of doing it, but I am not yet good enough at rust to get it.

Thanks.

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.