From ef8dd81143f3c84c34242b19116c69c00093c2dc Mon Sep 17 00:00:00 2001 From: DoumanAsh Date: Fri, 8 Nov 2024 09:47:46 +0900 Subject: [PATCH] Bump minimal Rust version to 1.64 --- .github/workflows/rust.yml | 25 +++++++++++++++++++++++++ README.md | 2 +- src/lib.rs | 19 +------------------ 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2627a8c..d454672 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,5 +1,8 @@ name: Rust +env: + min_rust_version: "1.64.0" + on: push: paths-ignore: @@ -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 diff --git a/README.md b/README.md index 64c62d7..dda8342 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Static string buffer ## Requirements -- Rust 1.59 +- Rust 1.64 ## Features: diff --git a/src/lib.rs b/src/lib.rs index 9d583f6..7382a71 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -189,25 +189,8 @@ impl StrBuf { #[allow(clippy::missing_transmute_annotations)] ///Returns slice to already written data. pub const fn as_slice(&self) -> &[u8] { - //Layout is: (, ) - // - //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()) } }