Giter VIP home page Giter VIP logo

named-types-rs's Introduction

named-types-rs

Like Display or Debug but for type names.

This crate provides Named, a trait that provides a core::fmt::Displayable way to get a types Name. It is similar to core::any::type_name without paths, but should provide a more sensical name for something like std::io::Error, which would show up as Error with something like pretty-type-name, whereas this crate provides the name IoError.

The names for std are given based on the Duck Test, e.g. core::slice::Iter stays Iter conflicting with something like core::option::Iter because they behave like generic iterators, whereas std::io::Error does not behave like a generic Error but rather is a specific Error type for io operations.

Additionally a Named derive macro is provided for deriving the Named trait. This macro can be configured by attributing a derived type with #[named(...)]. The following options can be passed to the attribute:

  • rename = "..." to change the types name.
  • format = "..." to use a custom format string that accepts all non-ignored generic parameters. Overrides any rename = "..." parameters to format the types name.
  • ignore_all to ignore all generic parameters.
  • ignore = ... to ignore a generic parameter.
  • passthrough = ... to use the Named implementation of a generic parameter. Takes priority over other options.

To configure multiple options repeat the #[named(...)] attribute.

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.