anony 0.4.1

Anonymous struct
Documentation

Provides various anonymous type constructs

Macros

  • struct!: creates an instance of an anonymous struct.
use anony::r#struct;

let items = vec![1, 3, 5];

let x = r#struct! {
    color: "Red".to_owned(),
    // move the `items` variable to the struct
    items
};

assert_eq!(x.color, "Red");
assert_eq!(x.items, [1, 3, 5]);
use anony::join;

assert_eq!(join!(async { 2 }, async { "123" }).await, (2, "123"));

Example Macro Expansions

https://github.com/discreaminant2809/anony/blob/master/examples/expansions.rs

Features

  • serde: derives Serialize for anonymous structs. serde crate and its derive feature must exist in your crate.
  • future: enables Future anonymous types, such as join!.

Todos

  • "Functional traits": quickly create an instance of a struct implementing a trait having exactly one required method.
  • "Typing": a way to create a new instance of the same anonymous struct as the source.