Giter Site home page Giter Site logo

bitrate's People

Contributors

dfrankland avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bitrate's Issues

I want to fix things that I think is wrong in this lib

I've found many strange things about this lib:

  • There is no derives for PartialEq, Eq, PartialOrd, Ord
  • ext-traits
    1. Traits are generic, however, they don't need to, you can use Self:
      pub trait $TXExt {
          /// Wrap in `Bps`
          fn bps(self) -> Bps<Self>;
    2. You generate ext-traits for all integer types instead of implementing one trait (also default implementation can be used here)
      pub trait Ext {
          /// Wrap in `Bps`
          fn bps(self) -> Bps<Self> { Bps(self) }
          // ...
      }
          
      impl Ext for u8 {}
      // ...
      impl Ext for u128 {}    
    3. ext-trait can be easily implemented without macro (this will help IDE (and users too) understand what's going on, for example)
  • I think structs (Bps, Hertz, ...) should at least implement Add<Output = Self>, Sub<Output = Self>, Mul<Rhs = T, Output = Self>, Div<Rhs = T, Output = Self>
  • Into is implemented for structs, instead of From. From docs:

    One should always prefer implementing From over Into because implementing From automatically provides one with an implementation of Into thanks to the blanket implementation in the standard library.

  • Into/From could be implemented without macro (but this requires some more thinking and maybe adding dependency like num)
  • We could also implement TryFrom so users will be able to handle overflows
  • I'm not sure, but I think that the fields of the structs must be private with getters (like into_inner :: self -> T). This will likely prevent users from writing such code:
    (x.0 * 10).hz();
    // instead of
    x * 10;
    (maybe we should also provide method(s) like map :: self -> (impl FnOnce(T) -> T) -> T so it would be easier to work with these structs)

If you don't mind, I would like to fix this in a PRs.

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.