Skip to content

Commit

Permalink
Setup MSRV
Browse files Browse the repository at this point in the history
Drop outdated CI. New CI scripts will follow
  • Loading branch information
zakarumych committed Nov 11, 2024
1 parent 361088f commit 8e27d18
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 195 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/badge.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/check-platforms.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/check-targets.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/check-toolchains.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/lints.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/release-please.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/security.yml

This file was deleted.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ homepage = "https://github.com/zakarumych/allocator-api2"
repository = "https://github.com/zakarumych/allocator-api2"
readme = "README.md"
description = "Mirror of Rust's allocator API"
rust-version = "1.63"

[features]
alloc = []
std = ["alloc"]
default = ["std"]
nightly = []
fresh-rust = []

[dependencies]
serde = { version = "1.0", optional = true }
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ If feature is not provided, your library may not be compatible with the
rest of the users and cause compilation errors on nightly channel
when some other crate enables "allocator-api2/nightly" feature.

# Minimal Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.63 and up.
A feature "fresh-rust" bumps the MSRV to unspecified higher version, but should be compatible with
at least few latest stable releases. The feature enables some additional functionality:

* `CStr` without "std" feature

## License

Licensed under either of
Expand Down
22 changes: 22 additions & 0 deletions src/stable/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2204,6 +2204,27 @@ impl<A: Allocator> Extend<Box<str, A>> for alloc_crate::string::String {
}

#[cfg(not(no_global_oom_handling))]
#[cfg(feature = "std")]
impl Clone for Box<std::ffi::CStr> {
#[inline]
fn clone(&self) -> Self {
(**self).into()
}
}

#[cfg(not(no_global_oom_handling))]
#[cfg(feature = "std")]
impl From<&std::ffi::CStr> for Box<std::ffi::CStr> {
/// Converts a `&CStr` into a `Box<CStr>`,
/// by copying the contents into a newly allocated [`Box`].
fn from(s: &std::ffi::CStr) -> Box<std::ffi::CStr> {
let boxed: Box<[u8]> = Box::from(s.to_bytes_with_nul());
unsafe { Box::from_raw(Box::into_raw(boxed) as *mut std::ffi::CStr) }
}
}

#[cfg(not(no_global_oom_handling))]
#[cfg(feature = "fresh-rust")]
impl Clone for Box<core::ffi::CStr> {
#[inline]
fn clone(&self) -> Self {
Expand All @@ -2212,6 +2233,7 @@ impl Clone for Box<core::ffi::CStr> {
}

#[cfg(not(no_global_oom_handling))]
#[cfg(feature = "fresh-rust")]
impl From<&core::ffi::CStr> for Box<core::ffi::CStr> {
/// Converts a `&CStr` into a `Box<CStr>`,
/// by copying the contents into a newly allocated [`Box`].
Expand Down
2 changes: 1 addition & 1 deletion src/stable/unique.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<T: ?Sized> Unique<T> {
pub const unsafe fn as_ref(&self) -> &T {
// SAFETY: the caller must guarantee that `self` meets all the
// requirements for a reference.
unsafe { self.pointer.as_ref() }
unsafe { &*(self.as_ptr() as *const T) }
}

/// Mutably dereferences the content.
Expand Down
7 changes: 4 additions & 3 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
[package]
name = "allocator-api2-tests"
version = "0.2.15"
edition = "2021"
version = "0.2.19"
edition = "2018"
description = "Tests for allocators that implement the allocator API"
license = "MIT OR Apache-2.0"
documentation = "https://docs.rs/allocator-api2-tests"
homepage = "https://github.com/zakarumych/allocator-api2"
repository = "https://github.com/zakarumych/allocator-api2"
rust-version = "1.63"

[features]
nightly = ["allocator-api2/nightly"]

[dependencies]
allocator-api2 = { version = "=0.2.18", path = ".." }
allocator-api2 = { version = "=0.2.19", path = ".." }

0 comments on commit 8e27d18

Please sign in to comment.