Skip to content

Rewrite crate to operate on reference values #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
277b25b
Different rewrite approaches
phil-opp Jul 29, 2020
93fb1e1
Decide for foo.rs approach
phil-opp Jul 29, 2020
8be4430
Update documentation
phil-opp Jul 29, 2020
401a86b
Remove const_fn cargo feature
phil-opp Jul 29, 2020
59dd91d
Reorganize access module and make it public
phil-opp Jul 29, 2020
53fd257
Add constructor methods for read/write-only types
phil-opp Jul 29, 2020
b469f42
Make methods generic using `Deref` trait
phil-opp Jul 29, 2020
d0bcea2
Add methods for working with volatile slices
phil-opp Jul 29, 2020
1b4931d
Document `copy_into_slice` method
phil-opp Jul 29, 2020
4766a43
Add `as_slice`/`as_mut_slice` methods for volatile array references
phil-opp Jul 30, 2020
cfbd66e
Rename the 'nightly' feature to 'unstable'
phil-opp Jul 31, 2020
bf8031c
Document constructor functions
phil-opp Jul 31, 2020
93e7150
Provide a custom fmt::Debug implementation to prevent reading of writ…
phil-opp Jul 31, 2020
8682a86
Improve documentation of `Volatile::new`
phil-opp Jul 31, 2020
46a7603
Warn on missing documentation
phil-opp Jul 31, 2020
7dffe2c
Improve documentation
phil-opp Aug 19, 2020
dfbaa68
Run cargo fmt
phil-opp Aug 19, 2020
76e7657
Don't derive Default
phil-opp Aug 19, 2020
4ba88d3
Add `map`/`map_mut`/`extract_inner` methods
phil-opp Aug 19, 2020
fb7e6a5
Use map/map_mut for index/index_mut implementation
phil-opp Aug 19, 2020
a78fd04
Use map/map_mut for array to slice conversion methods
phil-opp Aug 19, 2020
eabda2e
Add documentation for slice index methods
phil-opp Aug 19, 2020
2e272d6
Fix typo in docs
phil-opp Aug 19, 2020
d120638
Change order of impl blocks to show `read`/`write` methods first in docs
phil-opp Aug 19, 2020
966bea9
Enable `unstable` feature when building docs on docs.rs
phil-opp Aug 19, 2020
408a5f1
Create a CI workflow
phil-opp Aug 19, 2020
9bc9f95
Fix as_slice/as_mut_slice
phil-opp Aug 19, 2020
267ef61
Add `fill` and `copy_within` methods for slices
phil-opp Sep 9, 2020
401c5ba
Derive `Debug` and `Clone` for access types
phil-opp Sep 21, 2020
a4ccd3d
Document new slice methods
phil-opp Sep 21, 2020
2eaa1d6
Update check_range call for latest nightly
phil-opp Sep 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md
#
# While our "example" application has the platform-specific code,
# for simplicity we are compiling and testing everything on the Ubuntu environment only.
# For multi-OS testing see the `cross.yml` workflow.

on: [push, pull_request]

name: Build

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check

test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test

unstable:
name: Test Suite (unstable)
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true

- name: Run cargo test --features unstable
uses: actions-rs/cargo@v1
with:
command: test
args: --features unstable


lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ repository = "https://github.com/phil-opp/volatile"
[dependencies]

[features]
const_fn = []
# Enable unstable features; requires Rust nightly; might break on compiler updates
unstable = []

[package.metadata.release]
no-dev-version = true
pre-release-replacements = [
{ file="Changelog.md", search="# Unreleased", replace="# Unreleased\n\n# {{version}} – {{date}}", exactly=1 },
]
pre-release-commit-message = "Release version {{version}}"

[package.metadata.docs.rs]
features = ["unstable"]
22 changes: 22 additions & 0 deletions src/access.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// Helper trait that is implemented by [`ReadWrite`] and [`ReadOnly`].
pub trait Readable {}

/// Helper trait that is implemented by [`ReadWrite`] and [`WriteOnly`].
pub trait Writable {}

/// Zero-sized marker type for allowing both read and write access.
#[derive(Debug, Copy, Clone)]
pub struct ReadWrite;
impl Readable for ReadWrite {}
impl Writable for ReadWrite {}

/// Zero-sized marker type for allowing only read access.
#[derive(Debug, Copy, Clone)]
pub struct ReadOnly;

impl Readable for ReadOnly {}

/// Zero-sized marker type for allowing only write access.
#[derive(Debug, Copy, Clone)]
pub struct WriteOnly;
impl Writable for WriteOnly {}
Loading