Skip to content

Commit 6e07fd7

Browse files
committed
Replace 'no_std' feature with 'std' feature
Features should be additive. From the Cargo Book (https://doc.rust-lang.org/cargo/reference/features.html): For example, if you want to optionally support no_std environments, do not use a no_std feature. Instead, use a std feature that enables std.
1 parent c2f6cc2 commit 6e07fd7

File tree

12 files changed

+54
-56
lines changed

12 files changed

+54
-56
lines changed

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ name = "benchmark"
2929
harness = false
3030

3131
[features]
32-
default = []
32+
default = ["hashbrown/nightly"]
3333
# use `cargo bench --features sbench` only if you want benchmarks with 10 million
3434
# iterations (may fail on some systems)
3535
sbench = []
3636

37-
# nightly feature for `no_std`
38-
# for build use `cargo +nightly build --features no_std`
39-
no_std = ["hashbrown/nightly"]
37+
std = []
4038

4139
[package.metadata.docs.rs]
4240
features = ["dot"]

src/dot.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
use crate::{Graph, GraphErr, VertexId};
22

3-
#[cfg(feature = "no_std")]
3+
#[cfg(not(feature = "std"))]
44
use core::io::Write;
55

6-
#[cfg(not(feature = "no_std"))]
6+
#[cfg(feature = "std")]
77
use std::io::Write;
88

9-
#[cfg(feature = "no_std")]
9+
#[cfg(not(feature = "std"))]
1010
use core::borrow::Cow;
1111

12-
#[cfg(not(feature = "no_std"))]
12+
#[cfg(feature = "std")]
1313
use std::borrow::Cow;
1414

15-
#[cfg(feature = "no_std")]
15+
#[cfg(not(feature = "std"))]
1616
use core::fmt::Debug;
1717

18-
#[cfg(not(feature = "no_std"))]
18+
#[cfg(feature = "std")]
1919
use std::fmt::Debug;
2020

2121
type Nd = VertexId;

src/edge.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Copyright 2019 Octavian Oncescu
22

33
use crate::vertex_id::VertexId;
4-
#[cfg(not(feature = "no_std"))]
4+
#[cfg(feature = "std")]
55
use std::hash::Hash;
6-
#[cfg(not(feature = "no_std"))]
6+
#[cfg(feature = "std")]
77
use std::hash::Hasher;
88

9-
#[cfg(feature = "no_std")]
9+
#[cfg(not(feature = "std"))]
1010
extern crate alloc;
11-
#[cfg(feature = "no_std")]
11+
#[cfg(not(feature = "std"))]
1212
use core::hash::{Hash, Hasher};
1313

1414
#[derive(Clone, Debug)]

src/graph.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ use crate::iterators::*;
55
use crate::vertex_id::VertexId;
66
use hashbrown::{HashMap, HashSet};
77

8-
#[cfg(feature = "no_std")]
8+
#[cfg(not(feature = "std"))]
99
use core::iter;
10-
#[cfg(not(feature = "no_std"))]
10+
#[cfg(feature = "std")]
1111
use std::iter;
1212

13-
#[cfg(feature = "no_std")]
13+
#[cfg(not(feature = "std"))]
1414
use core::fmt::Debug;
15-
#[cfg(not(feature = "no_std"))]
15+
#[cfg(feature = "std")]
1616
use std::fmt::Debug;
1717

18-
#[cfg(feature = "no_std")]
18+
#[cfg(not(feature = "std"))]
1919
extern crate alloc;
20-
#[cfg(feature = "no_std")]
20+
#[cfg(not(feature = "std"))]
2121
use alloc::boxed::Box;
22-
#[cfg(feature = "no_std")]
22+
#[cfg(not(feature = "std"))]
2323
use alloc::vec;
24-
#[cfg(feature = "no_std")]
24+
#[cfg(not(feature = "std"))]
2525
use alloc::vec::Vec;
2626

2727
#[cfg(feature = "dot")]

src/iterators/bfs.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ use crate::graph::Graph;
44
use crate::vertex_id::VertexId;
55

66
use hashbrown::HashSet;
7-
#[cfg(not(feature = "no_std"))]
7+
#[cfg(feature = "std")]
88
use std::collections::VecDeque;
99

10-
#[cfg(feature = "no_std")]
10+
#[cfg(not(feature = "std"))]
1111
extern crate alloc;
12-
#[cfg(feature = "no_std")]
12+
#[cfg(not(feature = "std"))]
1313
use alloc::collections::vec_deque::VecDeque;
1414

15-
#[cfg(feature = "no_std")]
15+
#[cfg(not(feature = "std"))]
1616
use alloc::vec::Vec;
1717

18-
#[cfg(feature = "no_std")]
18+
#[cfg(not(feature = "std"))]
1919
use core::fmt::Debug;
2020

21-
#[cfg(not(feature = "no_std"))]
21+
#[cfg(feature = "std")]
2222
use std::fmt::Debug;
2323

2424
#[derive(Debug)]

src/iterators/dfs.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ use crate::graph::Graph;
44
use crate::iterators::VertexIter;
55
use crate::vertex_id::VertexId;
66

7-
#[cfg(feature = "no_std")]
7+
#[cfg(not(feature = "std"))]
88
use core::iter::{Chain, Cloned, Peekable};
99
use hashbrown::HashSet;
10-
#[cfg(not(feature = "no_std"))]
10+
#[cfg(feature = "std")]
1111
use std::iter::{Chain, Cloned, Peekable};
1212

13-
#[cfg(feature = "no_std")]
13+
#[cfg(not(feature = "std"))]
1414
extern crate alloc;
15-
#[cfg(feature = "no_std")]
15+
#[cfg(not(feature = "std"))]
1616
use alloc::vec::Vec;
1717

18-
#[cfg(feature = "no_std")]
18+
#[cfg(not(feature = "std"))]
1919
use core::fmt::Debug;
2020

21-
#[cfg(not(feature = "no_std"))]
21+
#[cfg(feature = "std")]
2222
use std::fmt::Debug;
2323

2424
#[derive(Debug)]

src/iterators/dijkstra.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::vertex_id::VertexId;
88
use hashbrown::HashMap;
99
use hashbrown::HashSet;
1010

11-
#[cfg(not(feature = "no_std"))]
11+
#[cfg(feature = "std")]
1212
use std::{
1313
cmp::Ordering,
1414
collections::{BinaryHeap, VecDeque},
@@ -17,14 +17,14 @@ use std::{
1717
iter,
1818
};
1919

20-
#[cfg(feature = "no_std")]
20+
#[cfg(not(feature = "std"))]
2121
extern crate alloc;
22-
#[cfg(feature = "no_std")]
22+
#[cfg(not(feature = "std"))]
2323
use alloc::boxed::Box;
24-
#[cfg(feature = "no_std")]
24+
#[cfg(not(feature = "std"))]
2525
use alloc::collections::{binary_heap::BinaryHeap, vec_deque::VecDeque};
2626

27-
#[cfg(feature = "no_std")]
27+
#[cfg(not(feature = "std"))]
2828
use core::{cmp::Ordering, f32, fmt::Debug, iter};
2929

3030
#[derive(PartialEq, Debug)]

src/iterators/owning_iterator.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
use crate::vertex_id::VertexId;
44

5-
#[cfg(not(feature = "no_std"))]
5+
#[cfg(feature = "std")]
66
use std::fmt::Debug;
77

8-
#[cfg(not(feature = "no_std"))]
8+
#[cfg(feature = "std")]
99
use std::marker::PhantomData;
1010

11-
#[cfg(feature = "no_std")]
11+
#[cfg(not(feature = "std"))]
1212
use core::marker::PhantomData;
1313

14-
#[cfg(feature = "no_std")]
14+
#[cfg(not(feature = "std"))]
1515
use core::mem;
1616

17-
#[cfg(not(feature = "no_std"))]
17+
#[cfg(feature = "std")]
1818
use std::mem;
1919

20-
#[cfg(not(feature = "no_std"))]
20+
#[cfg(feature = "std")]
2121
use std::collections::VecDeque;
2222

23-
#[cfg(feature = "no_std")]
23+
#[cfg(not(feature = "std"))]
2424
use alloc::collections::VecDeque;
2525

2626
/// Iterator that owns the data.

src/iterators/topo.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use crate::vertex_id::VertexId;
55

66
use hashbrown::HashMap;
77

8-
#[cfg(feature = "no_std")]
8+
#[cfg(not(feature = "std"))]
99
use alloc::vec::Vec;
1010

11-
#[cfg(feature = "no_std")]
11+
#[cfg(not(feature = "std"))]
1212
use core::fmt::Debug;
1313

14-
#[cfg(not(feature = "no_std"))]
14+
#[cfg(feature = "std")]
1515
use std::fmt::Debug;
1616

1717
const PANIC_MSG: &str = "graph contains cycle(s)";

src/iterators/values.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright 2019 Octavian Oncescu
22

3-
#[cfg(feature = "no_std")]
3+
#[cfg(not(feature = "std"))]
44
extern crate alloc;
5-
#[cfg(feature = "no_std")]
5+
#[cfg(not(feature = "std"))]
66
use alloc::boxed::Box;
77

88
/// Generic values Iterator.

src/iterators/vertices.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Copyright 2019 Octavian Oncescu
22

33
use crate::vertex_id::VertexId;
4-
#[cfg(feature = "no_std")]
4+
#[cfg(not(feature = "std"))]
55
use core::fmt::Debug;
6-
#[cfg(feature = "no_std")]
6+
#[cfg(not(feature = "std"))]
77
extern crate alloc;
8-
#[cfg(feature = "no_std")]
8+
#[cfg(not(feature = "std"))]
99
use alloc::boxed::Box;
10-
#[cfg(not(feature = "no_std"))]
10+
#[cfg(feature = "std")]
1111
use std::fmt::Debug;
1212

1313
pub(crate) trait MergedTrait<'a>: Iterator<Item = &'a VertexId> + Debug {}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ pub(crate) fn gen_bytes() -> [u8; 16] {
7070
)))
7171
}
7272

73-
#[cfg(feature = "no_std")]
73+
#[cfg(not(feature = "std"))]
7474
#[macro_use]
7575
extern crate alloc;

0 commit comments

Comments
 (0)