docs.rs failed to build extprim_literals-1.0.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
extprim_literals-2.0.3
Literal macros for extprim
.
This crate provides a compiler plugin (on nightly) or syntex extension (on stable) so that the
extprim
types can be constructed at compile-time using the i128!()
and u128!()
macros.
Setup as compiler plugin (nightly)
Add extprim_literals
to the dev-dependencies in Cargo.toml
:
[]
= "1.0.1"
Then just use the plugin:
use u128;
const TEN: u128 = u128!;
Setup as syntex extension (stable)
Supply a build.rs
, and add syntex
and extprim_literals
to the build-dependencies in
Cargo.toml
:
[]
= "build.rs"
[]
= "1.0.1"
= "0.31.0"
Register extprim_literals
to syntex
in build.rs
:
extern crate syntex;
extern crate extprim_literals;
use syntex::Registry;
use std::env;
use std::path::Path;
fn main() {
let mut registry = Registry::new();
extprim_literals::register(&mut registry);
let src = Path::new("src/consts.rs.in");
let dst = Path::new(&env::var("OUT_DIR").unwrap()).join("consts.rs");
registry.expand("extprim_literals", &src, &dst).unwrap();
}
Use the macros in src/consts.rs.in
:
use extprim::u128::u128;
const TEN: u128 = u128!(10);
Include the expanded file in src/consts.rs
:
include!(concat!(env!("OUT_DIR"), "/consts.rs"));