Skip to content

Commit

Permalink
Merge pull request #18 from Disasm/stable-const-fn
Browse files Browse the repository at this point in the history
Use stable const-fn
  • Loading branch information
korken89 committed Aug 29, 2019
2 parents 58c876c + 7f2c565 commit b58cc84
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 31 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@ name = "bare-metal"
repository = "https://github.com/japaric/bare-metal"
version = "0.2.4"

[features]
const-fn = []

[build-dependencies]
rustc_version = "0.2.3"
4 changes: 0 additions & 4 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ set -euxo pipefail
main() {
cargo check --target $TARGET

if [ $TRAVIS_RUST_VERSION = nightly ]; then
cargo check --target $TARGET --features const-fn
fi

if [ $TARGET = x86_64-unknown-linux-gnu ]; then
cargo test
fi
Expand Down
24 changes: 0 additions & 24 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

#![deny(missing_docs)]
#![deny(warnings)]
#![cfg_attr(
all(feature = "const-fn", unstable_const_fn),
feature(const_fn)
)]
#![no_std]

use core::cell::UnsafeCell;
Expand All @@ -23,23 +19,12 @@ impl<T> Peripheral<T> {
/// Creates a new peripheral
///
/// `address` is the base address of the register block
#[cfg(feature = "const-fn")]
pub const unsafe fn new(address: usize) -> Self {
Peripheral {
address: address as *mut T,
}
}

/// Creates a new peripheral
///
/// `address` is the base address of the register block
#[cfg(not(feature = "const-fn"))]
pub unsafe fn new(address: usize) -> Self {
Peripheral {
address: address as *mut T,
}
}

/// Borrows the peripheral for the duration of a critical section
pub fn borrow<'cs>(&self, _ctxt: &'cs CriticalSection) -> &'cs T {
unsafe { &*self.get() }
Expand Down Expand Up @@ -81,20 +66,11 @@ pub struct Mutex<T> {

impl<T> Mutex<T> {
/// Creates a new mutex
#[cfg(feature = "const-fn")]
pub const fn new(value: T) -> Self {
Mutex {
inner: UnsafeCell::new(value),
}
}

/// Creates a new mutex
#[cfg(not(feature = "const-fn"))]
pub fn new(value: T) -> Self {
Mutex {
inner: UnsafeCell::new(value),
}
}
}

impl<T> Mutex<T> {
Expand Down

0 comments on commit b58cc84

Please sign in to comment.