Skip to content

Commit 76e21dd

Browse files
committed
Remove stable feature
1 parent 21eb699 commit 76e21dd

File tree

11 files changed

+67
-265
lines changed

11 files changed

+67
-265
lines changed

lib/macro/Cargo.toml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,14 @@ version = "0.1.8"
44
authors = ["Julien Cretin <[email protected]>"]
55
license = "MIT"
66
edition = "2018"
7-
keywords = ["data-encoding", "macro", "static", "const", "compile-time"]
8-
categories = ["encoding"]
7+
keywords = ["no_std", "base64", "base32", "hex", "macro"]
8+
categories = ["encoding", "no-std"]
99
readme = "README.md"
1010
repository = "https://github.com/ia0/data-encoding"
1111
documentation = "https://docs.rs/data-encoding-macro"
1212
description = "Macros for data-encoding"
1313
include = ["Cargo.toml", "LICENSE", "README.md", "src/lib.rs"]
1414

15-
[package.metadata.docs.rs]
16-
no-default-features = true
17-
18-
[features]
19-
default = ["stable"]
20-
stable = ["data-encoding-macro-internal/stable", "proc-macro-hack"]
21-
2215
[dependencies]
23-
data-encoding = { version = "2.3", path = "..", default-features = false, features = ["alloc"] }
16+
data-encoding = { version = "2.3", path = "..", default-features = false }
2417
data-encoding-macro-internal = { version = "0.1.8", path = "internal" }
25-
proc-macro-hack = { version = "0.5", optional = true }

lib/macro/README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ encodings to be used with the [data-encoding] crate.
66
If you were familiar with the [binary_macros] crate, this library is actually
77
[inspired][binary_macros_issue] from it.
88

9-
If you use a nightly compiler, you may disable the "stable" feature:
10-
11-
```
12-
data-encoding-macro = { version = "0.1", default-features = false }
13-
```
14-
159
### Examples
1610

1711
You can define a compile-time byte slice or array (using the `hexlower` or
@@ -20,7 +14,7 @@ You can define a compile-time byte slice or array (using the `hexlower` or
2014
```rust
2115
const HELLO: &'static [u8] = &hexlower!("68656c6c6f");
2216
const FOOBAR: &'static [u8] = &base64!("Zm9vYmFy");
23-
// In nightly, it is possible to define an array instead of a slice:
17+
// It is possible to define an array instead of a slice:
2418
hexlower_array!("const HELLO" = "68656c6c6f");
2519
base64_array!("const FOOBAR" = "Zm9vYmFy");
2620
```

lib/macro/internal/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ include = ["Cargo.toml", "LICENSE", "README.md", "src/lib.rs"]
1212
[lib]
1313
proc-macro = true
1414

15-
[features]
16-
stable = ["proc-macro-hack"]
17-
1815
[dependencies]
19-
data-encoding = { version = "2.3", path = "../..", default-features = false, features = ["alloc"] }
20-
proc-macro-hack = { version = "0.5", optional = true }
16+
data-encoding = { version = "2.3", path = "../.." }
2117
syn = "1"

lib/macro/internal/src/lib.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,8 @@
99
1010
#![warn(unused_results)]
1111

12-
extern crate proc_macro;
13-
#[cfg(feature = "stable")]
14-
extern crate proc_macro_hack;
15-
extern crate syn;
16-
17-
extern crate data_encoding;
18-
1912
use proc_macro::token_stream::IntoIter;
2013
use proc_macro::{TokenStream, TokenTree};
21-
#[cfg(feature = "stable")]
22-
use proc_macro_hack::proc_macro_hack;
2314
use std::collections::HashMap;
2415

2516
use data_encoding::{BitOrder, Encoding, Specification, Translate, Wrap};
@@ -150,8 +141,7 @@ fn check_empty<T>(hash_map: HashMap<String, T>) {
150141
}
151142
}
152143

153-
#[cfg_attr(feature = "stable", proc_macro_hack)]
154-
#[cfg_attr(not(feature = "stable"), proc_macro)]
144+
#[proc_macro]
155145
#[doc(hidden)]
156146
pub fn internal_new_encoding(input: TokenStream) -> TokenStream {
157147
let mut hash_map = parse_map(input.into_iter());
@@ -160,7 +150,6 @@ pub fn internal_new_encoding(input: TokenStream) -> TokenStream {
160150
format!("{:?}", encoding.internal_implementation()).parse().unwrap()
161151
}
162152

163-
#[cfg(not(feature = "stable"))]
164153
#[proc_macro]
165154
#[doc(hidden)]
166155
pub fn internal_decode_array(input: TokenStream) -> TokenStream {
@@ -175,8 +164,7 @@ pub fn internal_decode_array(input: TokenStream) -> TokenStream {
175164
format!("{}: [u8; {}] = {:?};", name, output.len(), output).parse().unwrap()
176165
}
177166

178-
#[cfg_attr(feature = "stable", proc_macro_hack)]
179-
#[cfg_attr(not(feature = "stable"), proc_macro)]
167+
#[proc_macro]
180168
#[doc(hidden)]
181169
pub fn internal_decode_slice(input: TokenStream) -> TokenStream {
182170
let mut hash_map = parse_map(input.into_iter());

lib/macro/src/lib.rs

Lines changed: 17 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,33 @@
88
//! If you were familiar with the [binary_macros] crate, this library is
99
//! actually [inspired][binary_macros_issue] from it.
1010
//!
11-
//! If you use a nightly compiler, you may disable the "stable" feature:
12-
//!
13-
//! ```text
14-
//! data-encoding-macro = { version = "0.1", default-features = false }
15-
//! ```
16-
//!
17-
//! This library does not support no-std yet because it depends on a proc-macro library that depends
18-
//! on data-encoding with std and cargo propagates that feature although it's a build dependency.
19-
//! See https://github.com/rust-lang/cargo/issues/5730 for more information.
20-
//!
2111
//! # Examples
2212
//!
2313
//! You can define a compile-time byte slice from an encoded string literal:
2414
//!
2515
//! ```rust
26-
//! # #![cfg_attr(not(feature = "stable"), feature(proc_macro_hygiene))]
27-
//! #[macro_use]
28-
//! extern crate data_encoding_macro;
29-
//!
30-
//! const HELLO_SLICE: &'static [u8] = &hexlower!("68656c6c6f");
31-
//! const FOOBAR_SLICE: &'static [u8] = &base64!("Zm9vYmFy");
16+
//! const HELLO_SLICE: &'static [u8] = &data_encoding_macro::hexlower!("68656c6c6f");
17+
//! const FOOBAR_SLICE: &'static [u8] = &data_encoding_macro::base64!("Zm9vYmFy");
3218
//! # fn main() {}
3319
//! ```
3420
//!
35-
//! When you disable the "stable" feature (and use a nightly compiler), you can
36-
//! also define a compile-time byte array from an encoded string literal:
21+
//! You can also define a compile-time byte array from an encoded string literal:
3722
//!
3823
//! ```rust
39-
//! # #[macro_use] extern crate data_encoding_macro;
40-
//! # #[cfg(not(feature = "stable"))]
41-
//! hexlower_array!("const HELLO" = "68656c6c6f");
42-
//! # #[cfg(not(feature = "stable"))]
43-
//! base64_array!("const FOOBAR" = "Zm9vYmFy");
24+
//! data_encoding_macro::hexlower_array!("const HELLO" = "68656c6c6f");
25+
//! data_encoding_macro::base64_array!("const FOOBAR" = "Zm9vYmFy");
4426
//! # fn main() {}
4527
//! ```
4628
//!
4729
//! You can define a compile-time custom encoding from its specification:
4830
//!
4931
//! ```rust
50-
//! # #![cfg_attr(not(feature = "stable"), feature(proc_macro_hygiene))]
51-
//! extern crate data_encoding;
52-
//! #[macro_use]
53-
//! extern crate data_encoding_macro;
54-
//! use data_encoding::Encoding;
55-
//!
56-
//! const HEX: Encoding = new_encoding! {
32+
//! const HEX: data_encoding::Encoding = data_encoding_macro::new_encoding! {
5733
//! symbols: "0123456789abcdef",
5834
//! translate_from: "ABCDEF",
5935
//! translate_to: "abcdef",
6036
//! };
61-
//! const BASE64: Encoding = new_encoding! {
37+
//! const BASE64: data_encoding::Encoding = data_encoding_macro::new_encoding! {
6238
//! symbols: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
6339
//! padding: '=',
6440
//! };
@@ -72,32 +48,13 @@
7248
//! [data-encoding]: https://crates.io/crates/data-encoding
7349
//! [hexadecimal]: macro.hexlower_permissive.html
7450
75-
#![cfg_attr(not(feature = "stable"), feature(proc_macro_hygiene))]
76-
#![warn(unused_results)]
7751
#![no_std]
52+
#![warn(unused_results)]
7853

79-
#[cfg(feature = "stable")]
80-
extern crate proc_macro_hack;
81-
82-
extern crate data_encoding;
83-
extern crate data_encoding_macro_internal;
84-
85-
#[cfg(feature = "stable")]
86-
use proc_macro_hack::proc_macro_hack;
87-
88-
#[cfg(not(feature = "stable"))]
89-
#[doc(hidden)]
90-
pub use data_encoding_macro_internal::*;
91-
92-
#[cfg(feature = "stable")]
93-
#[proc_macro_hack]
94-
#[doc(hidden)]
95-
pub use data_encoding_macro_internal::internal_new_encoding;
96-
97-
#[cfg(feature = "stable")]
98-
#[proc_macro_hack]
9954
#[doc(hidden)]
100-
pub use data_encoding_macro_internal::internal_decode_slice;
55+
pub use data_encoding_macro_internal::{
56+
internal_decode_array, internal_decode_slice, internal_new_encoding,
57+
};
10158

10259
/// Defines a compile-time byte array by decoding a string literal
10360
///
@@ -110,10 +67,7 @@ pub use data_encoding_macro_internal::internal_decode_slice;
11067
/// # Examples
11168
///
11269
/// ```rust
113-
/// #[macro_use]
114-
/// extern crate data_encoding_macro;
115-
///
116-
/// decode_array! {
70+
/// data_encoding_macro::decode_array! {
11771
/// name: "const OCTAL",
11872
/// symbols: "01234567",
11973
/// padding: '=',
@@ -123,7 +77,6 @@ pub use data_encoding_macro_internal::internal_decode_slice;
12377
/// ```
12478
///
12579
/// [new_encoding]: macro.new_encoding.html
126-
#[cfg(not(feature = "stable"))]
12780
#[macro_export]
12881
macro_rules! decode_array {
12982
($($arg: tt)*) => {
@@ -141,11 +94,7 @@ macro_rules! decode_array {
14194
/// # Examples
14295
///
14396
/// ```rust
144-
/// # #![feature(proc_macro_hygiene)]
145-
/// #[macro_use]
146-
/// extern crate data_encoding_macro;
147-
///
148-
/// const OCTAL: &'static [u8] = &decode_slice! {
97+
/// const OCTAL: &'static [u8] = &data_encoding_macro::decode_slice! {
14998
/// symbols: "01234567",
15099
/// padding: '=',
151100
/// input: "237610==",
@@ -154,44 +103,13 @@ macro_rules! decode_array {
154103
/// ```
155104
///
156105
/// [new_encoding]: macro.new_encoding.html
157-
#[cfg(not(feature = "stable"))]
158106
#[macro_export]
159107
macro_rules! decode_slice {
160108
($($arg: tt)*) => {
161109
$crate::internal_decode_slice!($($arg)*)
162110
};
163111
}
164112

165-
/// Defines a compile-time byte slice by decoding a string literal
166-
///
167-
/// This macro takes a list of `key: value,` pairs (the last comma is required).
168-
/// It takes the key-value pairs specifying the encoding to use to decode the
169-
/// input (see [new_encoding] for the possible key-value pairs), the input
170-
/// itself keyed by `input`, and the output keyed by `name`.
171-
///
172-
/// # Examples
173-
///
174-
/// ```rust
175-
/// #[macro_use]
176-
/// extern crate data_encoding_macro;
177-
///
178-
/// const OCTAL: &'static [u8] = &decode_slice! {
179-
/// symbols: "01234567",
180-
/// padding: '=',
181-
/// input: "237610==",
182-
/// };
183-
/// # fn main() {}
184-
/// ```
185-
///
186-
/// [new_encoding]: macro.new_encoding.html
187-
#[cfg(feature = "stable")]
188-
#[macro_export]
189-
macro_rules! decode_slice {
190-
($($arg: tt)*) => {
191-
internal_decode_slice!($($arg)*)
192-
};
193-
}
194-
195113
/// Defines a compile-time custom encoding
196114
///
197115
/// This macro takes a list of `key: value,` pairs (the last comma is required).
@@ -215,57 +133,7 @@ macro_rules! decode_slice {
215133
/// # Examples
216134
///
217135
/// ```rust
218-
/// # #![feature(proc_macro_hygiene)]
219-
/// extern crate data_encoding;
220-
/// #[macro_use]
221-
/// extern crate data_encoding_macro;
222-
///
223-
/// const HEX: data_encoding::Encoding = new_encoding! {
224-
/// symbols: "0123456789abcdef",
225-
/// ignore: " \r\t\n",
226-
/// wrap_width: 32,
227-
/// wrap_separator: "\n",
228-
/// translate_from: "ABCDEF",
229-
/// translate_to: "abcdef",
230-
/// };
231-
/// # fn main() {}
232-
/// ```
233-
#[cfg(not(feature = "stable"))]
234-
#[macro_export]
235-
macro_rules! new_encoding {
236-
($($arg: tt)*) => {
237-
::data_encoding::Encoding::internal_new(&$crate::internal_new_encoding!{ $($arg)* })
238-
};
239-
}
240-
241-
/// Defines a compile-time custom encoding
242-
///
243-
/// This macro takes a list of `key: value,` pairs (the last comma is required).
244-
/// The possible key-value pairs are:
245-
///
246-
/// ```text
247-
/// symbols: <string>, // e.g. "01234567"
248-
/// padding: [None]|<char>, // e.g. '='
249-
/// bit_order: [MostSignificantFirst]|LeastSignificantFirst,
250-
/// check_trailing_bits: [true]|false,
251-
/// ignore: [""]|<string>, // e.g. " \t\n"
252-
/// wrap_width: [0]|<int>, // e.g. 76
253-
/// wrap_separator: [""]|<string>, // e.g. "\r\n"
254-
/// translate_from: [""]|<string>, // e.g. "ABCDEF"
255-
/// translate_to: [""]|<string>, // e.g. "abcdef"
256-
/// ```
257-
///
258-
/// Only `symbols` is required. Everything else is optional and defaults to the
259-
/// value between square brackets.
260-
///
261-
/// # Examples
262-
///
263-
/// ```rust
264-
/// extern crate data_encoding;
265-
/// #[macro_use]
266-
/// extern crate data_encoding_macro;
267-
///
268-
/// const HEX: data_encoding::Encoding = new_encoding! {
136+
/// const HEX: data_encoding::Encoding = data_encoding_macro::new_encoding! {
269137
/// symbols: "0123456789abcdef",
270138
/// ignore: " \r\t\n",
271139
/// wrap_width: 32,
@@ -275,27 +143,25 @@ macro_rules! new_encoding {
275143
/// };
276144
/// # fn main() {}
277145
/// ```
278-
#[cfg(feature = "stable")]
279146
#[macro_export]
280147
macro_rules! new_encoding {
281148
($($arg: tt)*) => {
282-
::data_encoding::Encoding::internal_new(&internal_new_encoding!{ $($arg)* })
149+
data_encoding::Encoding::internal_new(&$crate::internal_new_encoding!{ $($arg)* })
283150
};
284151
}
285152

286153
macro_rules! make {
287154
($base: ident $base_array: ident = $ref: ident; $($spec: tt)*) => {
288-
#[cfg(not(feature = "stable"))]
289155
#[macro_export]
290156
macro_rules! $base_array {
291157
($n: tt = $x: tt) => {
292-
decode_array!(name: $n, input: $x, $($spec)*);
158+
$crate::decode_array!(name: $n, input: $x, $($spec)*);
293159
};
294160
}
295161
#[macro_export]
296162
macro_rules! $base {
297163
($x: tt) => {
298-
decode_slice!(input: $x, $($spec)*)
164+
$crate::decode_slice!(input: $x, $($spec)*)
299165
};
300166
}
301167
#[test]

0 commit comments

Comments
 (0)