Skip to content

Commit 691cbf5

Browse files
bors[bot]japaric
andcommitted
Merge #5
5: improve DST support r=japaric a=japaric Co-authored-by: Jorge Aparicio <jorge@japaric.io>
2 parents baaf07e + 4c5b313 commit 691cbf5

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

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

66
## [Unreleased]
77

8+
## [v0.3.1] - 2018-11-07
9+
10+
### Changed
11+
12+
- Make deref work on Aligned<Ax, $DST>.
13+
814
## [v0.3.0] - 2018-11-05
915

1016
### Changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ keywords = ["alignment", "aligned", "array", "static"]
88
license = "MIT OR Apache-2.0"
99
name = "aligned"
1010
repository = "https://github.com/japaric/aligned"
11-
version = "0.3.0"
11+
version = "0.3.1"
1212

1313
[dependencies]
1414
as-slice = "0.1.0"

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub const fn Aligned<A, T>(value: T) -> Aligned<A, T> {
7272
impl<A, T> ops::Deref for Aligned<A, T>
7373
where
7474
A: sealed::Alignment,
75+
T: ?Sized,
7576
{
7677
type Target = T;
7778

@@ -83,6 +84,7 @@ where
8384
impl<A, T> ops::DerefMut for Aligned<A, T>
8485
where
8586
A: sealed::Alignment,
87+
T: ?Sized,
8688
{
8789
fn deref_mut(&mut self) -> &mut T {
8890
&mut self.value
@@ -147,4 +149,9 @@ fn sanity() {
147149
assert_eq!(mem::align_of_val(&*y), 4);
148150
assert_eq!(mem::align_of_val(&*z), 8);
149151
assert_eq!(mem::align_of_val(&*w), 16);
152+
153+
// test deref-ing
154+
let x: Aligned<A2, _> = Aligned([0u8; 3]);
155+
let y: &Aligned<A2, [u8]> = &x;
156+
let _: &[u8] = y;
150157
}

0 commit comments

Comments
 (0)