Giter Club home page Giter Club logo

structural_crates's Introduction

Build Status Join the chat at https://gitter.im/structural_crates/community

This library provides field accessor traits,and emulation of structural types.

Features

These are some of the features this library provides:

Examples

For examples you can look at the examples section of the documentation for the root module of the structural crate

Clarifications

The way that this library emulates structural types is by using traits as bounds or trait objects.

All the structural traits are dyn-compatible(also known as object-safe), and no change will be made to make them not dyn-compatible.

By default all structural types are open, structs and enums can have more variants and or fields than are required.
The only exception to this is exhaustive enums, in which the variant count and names must match exactly, this is useful for exhaustive matching of variants (in the switch macro).

Every trait with the _SI/_ESI/_VSI suffixes in the examples are traits generated by the Structural derive macro. These traits alias the accessor traits implemented by the type they're named after.

Required macros

The only macros that are required to use this crate are the ones for TStr, every other macro expands to code that can be written manually (except for the __TS type, that is an implementation detail that only macros from this crate should use by name).

Changelog

The changelog is in the "Changelog.md" file.

Future plans

Making the FromStructural and TryFromStructural traits derivable.

no-std support

To use structural in no_std contexts disable the default-feature.

structural={version="0.4",default_features=false}

This crate has few items that require the std crate (instead of core).

The "std" and "alloc" features are enabled by default so that users that are not aware of the core/alloc crates don't have to pass a feature to enable std support.

Cargo Features

These are the cargo features in structural:

  • std: Enables std support,this is enabled by default.

  • alloc: Enables alloc crate support,this is enabled by default.

  • specialization: Enables specialization inside structural,without enabling the nightly feature flag. This is for the case that specialization is stabilized after the last update to this library.

  • nightly_specialization: Enables specialization inside structural, requires nightly because it enables the nightly feature.

  • impl_fields: This allows using field_name: impl Foo fields in the structural_alias macro, which as of 2020-03-21 requires the associated_type_bounds Rust nightly feature.
    If this doesn't work,try using the "nightly_impl_fields" feature in Rust nightly instead.

  • nightly_impl_fields Equivalent to the impl_fields feature, as well as enabling the associated_type_bounds nightly features required for using the feature as of 2020-03-21.

  • use_const_str: Changes the internal implementation of TStr (the type level string type) to use a &'static str const parameter instead of types.
    Use this if const generics (eg:struct Foo<const S: &'static str>;) are usable on stable.

  • nightly_use_const_str: Equivalent to the use_const_str feature, which also enables the nightly Rust features required for const generics as of 2020-03-21.

  • disable_const_str: Disables const generics, useful if other crates enabling const generics causes internal errors in this Rust version.

Specialization is used inside structural for performance reasons. There are no benchmarks comparing when specialization is enabled and disabled yet.

Minimum Rust version

This crate support Rust back to 1.40, and uses a build script to automatically enable features from newer versions.

It requires Rust 1.40 to use proc macros in type position,eg: TS and FP.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Structural by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

structural_crates's People

Contributors

rodrimati1992 avatar ralfjung avatar

Stargazers

 avatar Arvid Gerstmann avatar dzmitry-lahoda avatar Matthijs Brobbel avatar  avatar Rogério Senna avatar Maxim Fischuk avatar Andrey Kuznetsov avatar Jack Wrenn avatar Jeff Burdges avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar

Forkers

ralfjung cor

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.