smacro 0.1.0

A collection of convenient Rust macros to reduce boilerplate
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented4 out of 4 items with examples
  • Size
  • Source code size: 17.29 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 329.14 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • saverioscagnoli/smacro
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • saverioscagnoli

smacro

A collection of convenient Rust macros to reduce boilerplate and improve ergonomics.

By default, only macros with no_std support are enabled. To enable more, just add the corresponding features.

Macros

s!

A versatile macro for creating String instances with minimal syntax.

use smacro::s;

// Empty string
let empty = s!();

// Convert anything with ToString
let hello = s!("Hello, world!");
let number = s!(42);

// Format strings
let name = "Alice";
let greeting = s!("Hello, {}!", name);

set! - Requires set feature

Create HashSet instances with initial values.

use smacro::set;

// Empty set
let empty = set!();

// Set with values
let numbers = set!(1, 2, 3, 4);
let fruits = set!("apple", "banana", "orange");

map! - Requires map feature

Create HashMap instances with key-value pairs.

use smacro::map;

// Empty map
let empty = map![];

// Map with initial data
let colors = map![
    "red" => "#FF0000",
    "green" => "#00FF00",
    "blue" => "#0000FF"
];

License

MIT, see LICENSE