Skip to content

Commit

Permalink
Update everything and add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
djkoloski committed Aug 11, 2024
1 parent 71b8feb commit 15cd01c
Show file tree
Hide file tree
Showing 26 changed files with 412 additions and 386 deletions.
4 changes: 4 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[build]
rustdocflags = ["--cfg", "docsrs"]

[env]
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: djkoloski
128 changes: 128 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: "0 10 * * *"

permissions:
contents: read

env:
RUSTFLAGS: -Dwarnings

jobs:
toolchain:
name: Toolchain / ${{ matrix.toolchain }} ${{ matrix.opt }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
- stable
- beta
- nightly
opt:
- ''
- --release

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- run: cargo test --verbose ${{ matrix.opt }}

miri:
name: Miri / ${{ matrix.opt }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
opt:
- ''
- --release

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@miri
- run: cargo miri setup
- run: cargo miri test ${{ matrix.opt }} --verbose
env:
MIRIFLAGS: -Zmiri-disable-stacked-borrows -Zmiri-tree-borrows

test:
name: Test / ${{ matrix.target }} ${{ matrix.opt }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
opt:
- ''
- --release
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test ${{ matrix.opt }}

cross:
name: Cross / ${{ matrix.target }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
target:
- i686-unknown-linux-gnu
- i586-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- aarch64-unknown-linux-gnu
- thumbv6m-none-eabi

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cross
- run: cross build --no-default-features --target ${{ matrix.target }} --verbose

format:
name: Format
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --check

clippy:
name: Clippy
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- run: cargo clippy

doc:
name: Doc
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo doc
14 changes: 9 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ version = "0.4.0"
authors = ["David Koloski <djkoloski@gmail.com>"]
edition = "2021"
license = "MIT"
readme = "README.md"
repository = "https://github.com/djkoloski/munge"
keywords = ["macro", "no_std"]
categories = ["no-std", "no-std::no-alloc", "rust-patterns"]

[workspace.dependencies]
munge_macro = { version = "0.4.0", path = "munge_macro" }
proc-macro2 = "1.0"
quote = "1.0"
syn = "2.0"
trybuild = "1.0"
munge_macro = { version = "=0.4.0", default-features = false, path = "munge_macro" }
proc-macro2 = { version = "1", default-features = false }
quote = { version = "1", default-features = false }
rustversion = { version = "1", default-features = false }
syn = { version = "2", default-features = false }
trybuild = { version = "1", default-features = false }
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 David Koloski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# `munge`

`munge` makes it easy and safe to destructure `MaybeUninit`s, `Cell`s,
[![crates.io badge]][crates.io] [![docs badge]][docs] [![license badge]][license]

[crates.io badge]: https://img.shields.io/crates/v/munge.svg
[crates.io]: https://crates.io/crates/munge
[docs badge]: https://img.shields.io/docsrs/munge
[docs]: https://docs.rs/munge
[license badge]: https://img.shields.io/badge/license-MIT-blue.svg
[license]: https://github.com/rkyv/munge/blob/master/LICENSE

Munge makes it easy and safe to destructure `MaybeUninit`s, `Cell`s,
`UnsafeCell`s, `ManuallyDrop`s, and more.

Just use the `munge!` macro to destructure opaque types the same way you'd
Expand All @@ -9,17 +18,15 @@ destructuring (e.g. `let (a, b) = c` where `c` is a reference) or move
destructuring (e.g. `let (a, b) = c` where `c` is a value) depending on the
type.

`munge` has no features and is always `#![no_std]`.
Munge has no features and is always `#![no_std]`.

## Examples

`munge` makes it easy to initialize `MaybeUninit`s:
Initialize `MaybeUninit`s:

```rust
use {
::core::mem::MaybeUninit,
::munge::munge,
};
use core::mem::MaybeUninit;
use munge::munge;

pub struct Example {
a: u32,
Expand All @@ -42,13 +49,11 @@ assert_eq!(init.b.0, 'x');
assert_eq!(init.b.1, 3.14);
```

It can also be used to destructure `Cell`s:
Destructure `Cell`s:

```rust
use {
::core::cell::Cell,
::munge::munge,
};
use core::cell::Cell;
use munge::munge;

pub struct Example {
a: u32,
Expand All @@ -75,7 +80,7 @@ assert_eq!(value.b.0, '!');
assert_eq!(value.b.1, 1.41);
```

You can even extend `munge` to work with your own types by implementing its
You can even extend munge to work with your own types by implementing its
`Destructure` and `Restructure` traits:

```rust
Expand Down
7 changes: 4 additions & 3 deletions munge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
keywords.workspace = true
categories.workspace = true
documentation = "https://docs.rs/munge"
keywords = ["munge", "macro", "destructure"]
categories = ["no-std", "rust-patterns"]
readme = "crates-io.md"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
munge_macro.workspace = true

[dev-dependencies]
rustversion.workspace = true
trybuild.workspace = true
7 changes: 7 additions & 0 deletions munge/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 David Koloski

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 15cd01c

Please sign in to comment.