Skip to content

Commit 4f835ec

Browse files
committed
Notes on Rust 2018 macro syntax
1 parent 8e13bb8 commit 4f835ec

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
target
1+
/target/
22
Cargo.lock

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[package]
22
name = "static_assert_macro"
3-
version = "1.0.3"
3+
version = "1.0.4"
44
authors = ["NODA, Kai <[email protected]>"]
55
description = "Library implementation of so-called `static_assert`"
66
documentation = "https://nodakai.github.io/rust-static_assert_macro/static_assert_macro"
77
repository = "https://github.com/nodakai/rust-static_assert_macro"
88
keywords = ["static_assert", "static", "assert"]
99
readme = "README.md"
1010
license = "Apache-2.0"
11+
edition = "2015"

README.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@
77
Cargo.toml:
88

99
[dependencies]
10-
static_assert_macro = "1.0.0"
10+
static_assert_macro = "1"
1111

12-
Your code:
12+
Your code (Rust 2018):
13+
14+
use static_assert_macro::static_assert;
15+
16+
static_assert!(1 < 2);
17+
18+
fn main() {
19+
static_assert!(3 < 4, 10 < 10);
20+
}
21+
22+
For Rust 2015 code, replace `use static_assert_macro::static_assert;` with
1323

1424
#[macro_use]
1525
extern crate static_assert_macro;
16-
17-
static_assert!(1 < 2);
1826

1927
For more details, visit
2028

src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
//!
1212
//! ## Example
1313
//! ```
14+
//! // Rust 2015 syntax
1415
//! #[macro_use]
1516
//! extern crate static_assert_macro;
1617
//!
18+
//! #[cfg(feature = "Rust 2018 syntax")]
19+
//! use static_assert_macro::static_assert;
20+
//!
1721
//! static_assert!(0 < 1, 1 < 2, 2 < 3);
1822
//!
1923
//! fn main() {

0 commit comments

Comments
 (0)