Skip to content

Commit e2a641b

Browse files
authored
Merge pull request #13 from rust-osdev/rewrite
Rewrite crate to operate on reference values
2 parents 51855f4 + 2eaa1d6 commit e2a641b

File tree

4 files changed

+806
-170
lines changed

4 files changed

+806
-170
lines changed

.github/workflows/build.yml

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md
2+
#
3+
# While our "example" application has the platform-specific code,
4+
# for simplicity we are compiling and testing everything on the Ubuntu environment only.
5+
# For multi-OS testing see the `cross.yml` workflow.
6+
7+
on: [push, pull_request]
8+
9+
name: Build
10+
11+
jobs:
12+
check:
13+
name: Check
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout sources
17+
uses: actions/checkout@v2
18+
19+
- name: Install stable toolchain
20+
uses: actions-rs/toolchain@v1
21+
with:
22+
profile: minimal
23+
toolchain: stable
24+
override: true
25+
26+
- name: Run cargo check
27+
uses: actions-rs/cargo@v1
28+
with:
29+
command: check
30+
31+
test:
32+
name: Test Suite
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout sources
36+
uses: actions/checkout@v2
37+
38+
- name: Install stable toolchain
39+
uses: actions-rs/toolchain@v1
40+
with:
41+
profile: minimal
42+
toolchain: stable
43+
override: true
44+
45+
- name: Run cargo test
46+
uses: actions-rs/cargo@v1
47+
with:
48+
command: test
49+
50+
unstable:
51+
name: Test Suite (unstable)
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout sources
55+
uses: actions/checkout@v2
56+
57+
- name: Install nightly toolchain
58+
uses: actions-rs/toolchain@v1
59+
with:
60+
profile: minimal
61+
toolchain: nightly
62+
override: true
63+
64+
- name: Run cargo test --features unstable
65+
uses: actions-rs/cargo@v1
66+
with:
67+
command: test
68+
args: --features unstable
69+
70+
71+
lints:
72+
name: Lints
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout sources
76+
uses: actions/checkout@v2
77+
78+
- name: Install stable toolchain
79+
uses: actions-rs/toolchain@v1
80+
with:
81+
profile: minimal
82+
toolchain: stable
83+
override: true
84+
components: rustfmt, clippy
85+
86+
- name: Run cargo fmt
87+
uses: actions-rs/cargo@v1
88+
with:
89+
command: fmt
90+
args: --all -- --check
91+
92+
- name: Run cargo clippy
93+
uses: actions-rs/cargo@v1
94+
with:
95+
command: clippy

Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ repository = "https://github.com/phil-opp/volatile"
1111
[dependencies]
1212

1313
[features]
14-
const_fn = []
14+
# Enable unstable features; requires Rust nightly; might break on compiler updates
15+
unstable = []
1516

1617
[package.metadata.release]
1718
no-dev-version = true
1819
pre-release-replacements = [
1920
{ file="Changelog.md", search="# Unreleased", replace="# Unreleased\n\n# {{version}} – {{date}}", exactly=1 },
2021
]
2122
pre-release-commit-message = "Release version {{version}}"
23+
24+
[package.metadata.docs.rs]
25+
features = ["unstable"]

src/access.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/// Helper trait that is implemented by [`ReadWrite`] and [`ReadOnly`].
2+
pub trait Readable {}
3+
4+
/// Helper trait that is implemented by [`ReadWrite`] and [`WriteOnly`].
5+
pub trait Writable {}
6+
7+
/// Zero-sized marker type for allowing both read and write access.
8+
#[derive(Debug, Copy, Clone)]
9+
pub struct ReadWrite;
10+
impl Readable for ReadWrite {}
11+
impl Writable for ReadWrite {}
12+
13+
/// Zero-sized marker type for allowing only read access.
14+
#[derive(Debug, Copy, Clone)]
15+
pub struct ReadOnly;
16+
17+
impl Readable for ReadOnly {}
18+
19+
/// Zero-sized marker type for allowing only write access.
20+
#[derive(Debug, Copy, Clone)]
21+
pub struct WriteOnly;
22+
impl Writable for WriteOnly {}

0 commit comments

Comments
 (0)