Skip to content
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

Reorganize code for 1.64 Rust version #240

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
env:
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: 1
RUST_VERSION: 1.64.0

jobs:
# Depends on all actions that are required for a "successful" CI run.
Expand Down Expand Up @@ -54,9 +55,14 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout sources
uses: actions/checkout@v3
- name: Install Rust
run: rustup update stable
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
profile: minimal
override: true
- run: cargo test

test-docs:
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "tokio-uring"
version = "0.4.0"
authors = ["Tokio Contributors <team@tokio.rs>"]
edition = "2018"
rust-version = "1.64"
readme = "README.md"
license = "MIT"
documentation = "https://docs.rs/tokio-uring/0.4.0/tokio-uring"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ provides new resource types that work with [`io-uring`].
[`fs::File`]: https://docs.rs/tokio-uring/latest/tokio_uring/fs/struct.File.html

[API Docs](https://docs.rs/tokio-uring/latest/tokio_uring) |
[Chat](https://discord.gg/tokio)
[Chat](https://discord.gg/tokio) |
![rust 1.64.0 required](https://img.shields.io/badge/rust-1.64.0-blue.svg?label=MSRV)

# Getting started

Expand Down
32 changes: 16 additions & 16 deletions src/buf/fixed/plumbing/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,23 @@ impl<T: IoBufMut> Registry<T> {
// If the buffer is already checked out, returns None.
pub(crate) fn check_out(&mut self, index: usize) -> Option<CheckedOutBuf> {
let state = self.states.get_mut(index)?;
let BufState::Free { init_len } = *state else {
return None
};

*state = BufState::CheckedOut;
if let BufState::Free { init_len } = *state {
*state = BufState::CheckedOut;

// Safety: the allocated array under the pointer is valid
// for the lifetime of self, the index is inside the array
// as checked by Vec::get_mut above, called on the array of
// states that has the same length.
let iovec = unsafe { self.raw_bufs.as_ptr().add(index).read() };
debug_assert!(index <= u16::MAX as usize);
Some(CheckedOutBuf {
iovec,
init_len,
index: index as u16,
})
// Safety: the allocated array under the pointer is valid
// for the lifetime of self, the index is inside the array
// as checked by Vec::get_mut above, called on the array of
// states that has the same length.
let iovec = unsafe { self.raw_bufs.as_ptr().add(index).read() };
debug_assert!(index <= u16::MAX as usize);
Some(CheckedOutBuf {
iovec,
init_len,
index: index as u16,
})
} else {
None
}
}

fn check_in_internal(&mut self, index: u16, init_len: usize) {
Expand Down