Skip to content

Commit

Permalink
Ready 0.5 release
Browse files Browse the repository at this point in the history
Cleanup documentation.
Remove some stale types.
Simplify some methods.
Fix no_std issues.
Fix clippy warnings.
Update github workflows.

Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
  • Loading branch information
Caellian committed Mar 22, 2024
1 parent 1073272 commit 4a02aab
Show file tree
Hide file tree
Showing 18 changed files with 339 additions and 569 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: nightly
profile: minimal
components: clippy
override: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/semver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-semver-checks
version: "^0.23"
version: "^0.30"
- name: Run semver check
run: cargo semver-checks check-release
11 changes: 9 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ path = "examples/ptr_metadata.rs"
required-features = ["ptr_metadata"]

[features]
default = ["unsafe_impl", "ptr_metadata", "debug"]
default = [
"no_std",
"unsafe_impl",
"debug",
"ptr_metadata",
"error_in_core",
"allocator_api",
]

no_std = [] # No-std support
debug = [] # Enable debug attributes
debug = [] # Enable debug attributes

# Implementations
unsafe_impl = []
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# contiguous_mem

contiguous_mem is a vector like collection that can store entries with
heterogeneous layouts while retaining type safety at the reference level.
heterogeneous layouts while retaining type information at the reference level.

[![Crate](https://img.shields.io/crates/v/contiguous_mem?style=for-the-badge&logo=docs.rs)](https://crates.io/crates/contiguous_mem)
[![Documentation](https://img.shields.io/docsrs/contiguous-mem?style=for-the-badge&logo=rust)](https://docs.rs/contiguous-mem)
Expand Down Expand Up @@ -32,7 +32,8 @@ over when your scope and requirements shift.
## Use cases

- Storing differently typed/sized data. ([example](./examples/default_impl.rs))
- Ensuring stored data is placed adjacently in memory. ([example](./examples/game_loading.rs))
- Ensuring stored data is placed adjacently in memory.
([example](./examples/game_loading.rs))
- Note that returned references are **not** contiguous, only data they refer
to is.

Expand All @@ -42,14 +43,14 @@ Add the crate to your dependencies:

```toml
[dependencies]
contiguous_mem = { version = "0.4" }
contiguous_mem = { version = "0.5" }
```

Optionally enable `no_std` feature to use in `no_std` environment:

```toml
[dependencies]
contiguous_mem = { version = "0.4", features = ["no_std"] }
contiguous_mem = { version = "0.5", features = ["no_std"] }
```

### Features
Expand Down
2 changes: 1 addition & 1 deletion doc/crate.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
contiguous_mem is a vector like collection that can store entries with
heterogeneous layouts while retaining type safety at the reference level.
heterogeneous layouts while retaining type information at the reference level.

## Features

Expand Down
247 changes: 0 additions & 247 deletions doc/struct.md

This file was deleted.

4 changes: 4 additions & 0 deletions examples/default_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ fn main() {
// Retrieve and use the stored data
assert_eq!(*stored_data.get(), data);
assert_eq!(*stored_number.get(), 22);

// All stored data gets cleaned up once `memory` goes out of scope, or we
// can forget it existed:
memory.forget();
}
28 changes: 14 additions & 14 deletions examples/game_loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ impl<T> IndexOrPtr<T> {
}

pub trait Load {
/// # Safety
///
/// Loading is unsafe, that's why the game is so fun - you don't know
/// whether you'll be able to continue playing if you ever stop.
unsafe fn load<R: Read>(data: R) -> Self;
}
pub trait Save {
Expand Down Expand Up @@ -177,22 +181,18 @@ fn main() {
);

// Create enemy lookup list.
let enemies: &[*const Enemy] = unsafe {
&[
data.push(load_game_file("enemy1.dat")),
data.push(load_game_file("enemy2.dat")),
data.push(load_game_file("enemy3.dat")),
data.push(load_game_file("enemy4.dat")),
]
};
let enemies: &[*const Enemy] = &[
data.push(load_game_file("enemy1.dat")),
data.push(load_game_file("enemy2.dat")),
data.push(load_game_file("enemy3.dat")),
data.push(load_game_file("enemy4.dat")),
];

// Create level lookup list.
let levels: &[*mut Level] = unsafe {
&[
data.push(load_game_file("level1.dat")),
data.push(load_game_file("level2.dat")),
]
};
let levels: &[*mut Level] = &[
data.push(load_game_file("level1.dat")),
data.push(load_game_file("level2.dat")),
];

// data won't go out of scope while we're using it in this example, but in
// your use case it might. This is here for completeness.
Expand Down
2 changes: 1 addition & 1 deletion examples/ptr_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(ptr_metadata)]

use contiguous_mem::{memory::DefaultMemoryManager, types::ImplDefault, *};
use contiguous_mem::{types::ImplDefault, *};

trait Greetable {
fn print_hello(&self);
Expand Down
Loading

0 comments on commit 4a02aab

Please sign in to comment.