[package]
name = "bump-scope"
version = "1.1.0"
edition = "2024"
license = "MIT OR Apache-2.0"
description = "A fast bump allocator that supports allocation scopes / checkpoints. Aka an arena for values of arbitrary types."
categories = ["memory-management", "no-std", "no-std::no-alloc"]
keywords = ["allocator", "arena", "no-std", "bump", "allocation"]
documentation = "https://docs.rs/bump-scope"
repository = "https://github.com/bluurryy/bump-scope"
rust-version = "1.85.1"
readme = "README.md"
exclude = ["*.nu", "justfile", "tests", ".vscode", ".github"]

[dependencies]
allocator-api2-02 = { package = "allocator-api2", version = "0.2.21", default-features = false, optional = true }
allocator-api2-03 = { package = "allocator-api2", version = "0.3.0", default-features = false, optional = true }
bytemuck = { version = "1.23.0", default-features = false, optional = true }
zerocopy-08 = { package = "zerocopy", version = "0.8.14", default-features = false, optional = true }
serde = { version = "1.0.217", optional = true }

[features]
default = ["std", "alloc", "panic-on-alloc"]

## Adds `BumpPool` and implementations of `std::io` traits.
std = ["alloc", "allocator-api2-02?/std", "allocator-api2-03?/std"]

## Adds `Global` as the default base allocator and some interactions with `alloc` collections.
alloc = ["allocator-api2-02?/alloc", "allocator-api2-03?/alloc"]

## Adds functions and traits that will panic when the allocation fails. 
## Without this feature, allocation failures cannot cause panics, and only 
## `try_`-prefixed allocation methods will be available.
panic-on-alloc = []

## Adds `Serialize` implementations for `BumpBox`, strings and vectors, and `DeserializeSeed` for strings and vectors. 
serde = ["dep:serde"]

## Adds `bytemuck::*` extension traits for `alloc_zeroed(_slice)`, `BumpBox::init_zeroed` and 
## `resize_zeroed` and `extend_zeroed` for vector types. 
bytemuck = ["dep:bytemuck"]

## Adds `zerocopy_08::*` extension traits for `alloc_zeroed(_slice)`, `BumpBox::init_zeroed` and 
## `resize_zeroed` and `extend_zeroed` for vector types. 
zerocopy-08 = ["dep:zerocopy-08"]

## Makes `Bump(Scope)` implement `allocator_api2` version `0.2`'s `Allocator` and
## makes it possible to use an `allocator_api2::alloc::Allocator` as a base allocator via
## [`AllocatorApi2V02Compat`](crate::alloc::compat::AllocatorApi2V02Compat).
allocator-api2-02 = ["dep:allocator-api2-02"]

## Makes `Bump(Scope)` implement `allocator_api2` version `0.3`'s `Allocator` and
## makes it possible to use an `allocator_api2::alloc::Allocator` as a base allocator via
## [`AllocatorApi2V03Compat`](crate::alloc::compat::AllocatorApi2V03Compat).
allocator-api2-03 = ["dep:allocator-api2-03"]

#! ### Nightly features
#! These nightly features are not subject to the same semver guarantees as the rest of the library. 
#! Breaking changes to these features might be introduced in minor releases to keep up with changes in the nightly channel.

## Enables all other nightly feature flags.
nightly = [
    "nightly-allocator-api",
    "nightly-coerce-unsized",
    "nightly-exact-size-is-empty",
    "nightly-trusted-len",
    "nightly-fn-traits",
    "nightly-tests",
    "nightly-dropck-eyepatch",
    "nightly-clone-to-uninit",
]

## Makes `Bump(Scope)` implement `alloc`'s `Allocator` and
## allows using an `alloc::alloc::Allocator` as a base allocator via
## [`AllocatorNightlyCompat`](crate::alloc::compat::AllocatorNightlyCompat).
##
## This will also enable `allocator-api2` version `0.2`'s `nightly` feature.
nightly-allocator-api = ["allocator-api2-02/nightly"]

## Makes `BumpBox<T>` implement [`CoerceUnsized`](core::ops::CoerceUnsized).
## With this `BumpBox<[i32;3]>` coerces to `BumpBox<[i32]>`, `BumpBox<dyn Debug>` and so on.
## You can unsize a `BumpBox` in stable without this feature using [`unsize_bump_box`].
nightly-coerce-unsized = []

## Implements `is_empty` manually for some iterators.
nightly-exact-size-is-empty = []

## Implements `TrustedLen` for some iterators.
nightly-trusted-len = []

## Implements `Fn*` traits for `BumpBox<T>`. Makes `BumpBox<T: FnOnce + ?Sized>` callable. Requires alloc crate.
nightly-fn-traits = []

## Enables some tests that require a nightly compiler.
nightly-tests = []

## Adds `#[may_dangle]` attribute to box and vector types' drop implementation.
## This makes it so references don't have to strictly outlive the container.
## (That's how std's `Box` and `Vec` work.)
nightly-dropck-eyepatch = []

## Adds [`alloc_clone`](Bump::alloc_clone) method to `Bump(Scope)`.
nightly-clone-to-uninit = []

[dev-dependencies]
trybuild = "1.0.90"
expect-test = "1.4.1"
rayon = "1.10.0"
serde_json = "1.0.115"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--generate-link-to-definition"]

[package.metadata.release]
allow-branch = ["main"]
pre-release-hook = ["just", "pre-release"]
pre-release-commit-message = "release: version {{version}}"
pre-release-replacements = [
    { file = "CHANGELOG.md", search = "## \\[Unreleased\\]", replace = "## [{{version}}] - {{date}}", exactly = 1 },
    { file = "CHANGELOG.md", search = "\\[Unreleased\\]: .*", replace = "[{{version}}]: https://github.com/bluurryy/bump-scope/releases/tag/v{{version}}" },
    { file = "CHANGELOG.md", search = "#Unreleased", replace = "#{{version}}", min = 0 },
    { file = "CHANGELOG.md", search = "<!-- next-url -->", replace = "<!-- next-url -->\n[Unreleased]: https://github.com/bluurryy/cargo-insert-docs/compare/{{tag_name}}...HEAD", exactly = 1 },
    { file = "UPGRADING.md", search = "## \\[Unreleased\\]", replace = "## [{{version}}] - {{date}}", min = 0 },
    { file = "UPGRADING.md", search = "\\[Unreleased\\]: .*", replace = "[{{version}}]: CHANGELOG.md#{{version}}", min = 0 },
    { file = "UPGRADING.md", search = "#Unreleased", replace = "#{{version}}", min = 0 },
]
