Skip to content

Commit 86196aa

Browse files
committed
Make this library #[no_std] compatible.
1 parent a2ecfd5 commit 86196aa

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ description = "The uninhabited void type for use in statically impossible cases.
88
readme = "README.md"
99
license = "MIT"
1010

11+
[features]
12+
13+
default = [ "std" ]
14+
std = []
15+

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![cfg_attr(test, deny(warnings))]
22
#![deny(missing_docs)]
3+
#![cfg_attr(not(feature = "std"), no_std)]
34

45
//! # Void
56
//!
@@ -10,7 +11,11 @@
1011
//! extra functionality to `Result<T, Void>` and `Result<Void, E>`.
1112
//!
1213
13-
use std::{fmt, cmp, error};
14+
extern crate core;
15+
use core::{fmt, cmp};
16+
17+
#[cfg(feature = "std")]
18+
use std::error;
1419

1520
/// The empty type for cases which can't occur.
1621
#[derive(Copy)]
@@ -46,6 +51,7 @@ impl<T> cmp::PartialOrd<T> for Void {
4651
}
4752
}
4853

54+
#[cfg(feature = "std")]
4955
impl error::Error for Void {
5056
fn description(&self) -> &str {
5157
unreachable(*self)

0 commit comments

Comments
 (0)