Skip to content

Commit 113b38b

Browse files
bors[bot]japaric
andcommitted
Merge #2
2: add an opt-out "const-fn" Cargo feature r=japaric a=japaric to make this crate compilable on stable Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2 parents 8795b71 + 8ff33fe commit 113b38b

File tree

7 files changed

+82
-4
lines changed

7 files changed

+82
-4
lines changed

.travis.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
language: rust
2+
3+
matrix:
4+
include:
5+
- env: TARGET=x86_64-unknown-linux-gnu
6+
- env: TARGET=x86_64-unknown-linux-gnu
7+
rust: nightly
8+
9+
before_install: set -e
10+
11+
install:
12+
- bash ci/install.sh
13+
14+
script:
15+
- bash ci/script.sh
16+
17+
after_script: set +e
18+
19+
cache: cargo
20+
before_cache:
21+
# Travis can't cache files that are not readable by "others"
22+
- chmod -R a+r $HOME/.cargo
23+
24+
branches:
25+
only:
26+
- staging
27+
- trying
28+
29+
notifications:
30+
email:
31+
on_success: never

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased]
77

8+
## [v0.1.2] - 2018-04-25
9+
10+
### Added
11+
12+
- an opt-out "const-fn" Cargo feature. Disabling this feature removes all `const` constructors and
13+
makes this crate compilable on stable.
14+
815
## [v0.1.1] - 2017-05-30
916

1017
### Added
@@ -15,5 +22,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1522

1623
- Initial release
1724

18-
[Unreleased]: https://github.com/japaric/aligned/compare/v0.1.1...HEAD
25+
[Unreleased]: https://github.com/japaric/aligned/compare/v0.1.2...HEAD
26+
[v0.1.2]: https://github.com/japaric/aligned/compare/v0.1.1...v0.1.2
1927
[v0.1.1]: https://github.com/japaric/aligned/compare/v0.1.0...v0.1.1

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ keywords = ["alignment", "aligned", "array", "static"]
77
license = "MIT OR Apache-2.0"
88
name = "aligned"
99
repository = "https://github.com/japaric/aligned"
10-
version = "0.1.1"
10+
version = "0.1.2"
1111

12-
[dependencies]
12+
[features]
13+
const-fn = []
14+
default = ["const-fn"]

bors.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
status = [
2+
"continuous-integration/travis-ci/push",
3+
]

ci/install.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set -euxo pipefail
2+
3+
main() {
4+
:
5+
}
6+
7+
main

ci/script.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set -euxo pipefail
2+
3+
main() {
4+
cargo check --target $TARGET --no-default-features
5+
6+
if [ $TRAVIS_RUST_VERSION = nightly ]; then
7+
cargo check --target $TARGET
8+
fi
9+
}
10+
11+
main

src/lib.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
3030
#![deny(missing_docs)]
3131
#![deny(warnings)]
32-
#![feature(const_fn)]
32+
#![cfg_attr(feature = "const-fn", feature(const_fn))]
3333
#![no_std]
3434

3535
use core::{mem, ops};
@@ -165,6 +165,7 @@ unsafe impl Alignment for u64 {}
165165

166166
/// `Aligned` constructor
167167
#[allow(non_snake_case)]
168+
#[cfg(feature = "const-fn")]
168169
pub const fn Aligned<ALIGNMENT, ARRAY>(
169170
array: ARRAY,
170171
) -> Aligned<ALIGNMENT, ARRAY>
@@ -177,6 +178,21 @@ where
177178
}
178179
}
179180

181+
/// `Aligned` constructor
182+
#[allow(non_snake_case)]
183+
#[cfg(not(feature = "const-fn"))]
184+
pub fn Aligned<ALIGNMENT, ARRAY>(
185+
array: ARRAY,
186+
) -> Aligned<ALIGNMENT, ARRAY>
187+
where
188+
ALIGNMENT: Alignment,
189+
{
190+
Aligned {
191+
_alignment: [],
192+
array: array,
193+
}
194+
}
195+
180196
#[test]
181197
fn sanity() {
182198
use core::mem;

0 commit comments

Comments
 (0)