Skip to content

Commit

Permalink
Bump minimal Rust version to 1.64
Browse files Browse the repository at this point in the history
  • Loading branch information
DoumanAsh committed Nov 8, 2024
1 parent d13a241 commit ef8dd81
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Rust

env:
min_rust_version: "1.64.0"

on:
push:
paths-ignore:
Expand All @@ -16,6 +19,28 @@ on:
- '.gitignore'

jobs:
min-rust-check:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust Unix
run: |
if rustup --version >/dev/null 2>&1; then
rustup install ${{ env.min_rust_version }}
rustup default ${{ env.min_rust_version }}
else
curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain ${{ env.min_rust_version }}
echo ::add-path::$HOME/.cargo/bin
fi
- name: Rust version
run: |
cargo --version
rustc --version
- name: Check
run: |
cargo check --features serde,ufmt-write
check:
if: github.event.pull_request.draft == false
uses: DoumanAsh/douman-ci/.github/workflows/rust.yml@master
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Static string buffer

## Requirements

- Rust 1.59
- Rust 1.64

## Features:

Expand Down
19 changes: 1 addition & 18 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,25 +189,8 @@ impl<const N: usize> StrBuf<N> {
#[allow(clippy::missing_transmute_annotations)]
///Returns slice to already written data.
pub const fn as_slice(&self) -> &[u8] {
//Layout is: (<ptr>, <usize>)
//
//Reference:
//https://github.com/rust-lang/rust/blob/6830052c7b87217886324129bffbe096e485d415/library/core/src/ptr/metadata.rs#L145=
#[repr(C)]
struct RawSlice {
ptr: *const u8,
size: usize,
}

debug_assert!(unsafe {
mem::transmute::<_, RawSlice>([3, 2, 1].as_slice()).size
} == 3, "RawSlice layout has been changed in compiler unexpectedly");

unsafe {
mem::transmute(RawSlice {
ptr: self.as_ptr(),
size: self.len(),
})
slice::from_raw_parts(self.as_ptr(), self.len())
}
}

Expand Down

0 comments on commit ef8dd81

Please sign in to comment.