From 0941bde734a63bd1f31582730ea2a97b71699c7f Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Thu, 6 Jun 2024 18:24:37 +0200 Subject: [PATCH] Unconditionally enable `derive`, update changelog and upgrade docs --- CHANGELOG.md | 4 ++++ UPGRADE.md | 6 ++++++ rustler/Cargo.toml | 6 +++--- rustler/src/lib.rs | 1 - 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72782046..aace7bb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ versions. ### Added +- Resource types can now be registered implicitly via a `#[derive(Resource)]` + instead of explicit registration in a `load` function using + `rustler::resource!` (#617) + ### Fixed ### Changed diff --git a/UPGRADE.md b/UPGRADE.md index d48083a9..1b6595df 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -7,6 +7,12 @@ This document is intended to simplify upgrading to newer versions by extending t 1. NIF implementations are now discovered automatically, the respective argument in the `rustler::init!` macro should be removed. If a NIF implementation should not be exported, it must be disabled with a `#[cfg]` marker. +2. The functionality related to the `derive` feature is now unconditionally + active. The feature flag is kept for compatibility for now but will be + removed in the future. +3. To register a type as a resource, the new `#[derive(Resource)]` can be used + now. It is implicitly registered and does not require (or work in) the old + explicit registration with `rustler::resource!` a custom `load` function. ## 0.32 -> 0.33 diff --git a/rustler/Cargo.toml b/rustler/Cargo.toml index 4401f23a..333cee89 100644 --- a/rustler/Cargo.toml +++ b/rustler/Cargo.toml @@ -11,8 +11,8 @@ rust-version = "1.70" [features] big_integer = ["dep:num-bigint"] -default = ["derive", "nif_version_2_15"] -derive = ["rustler_codegen"] +default = ["nif_version_2_15"] +derive = [] alternative_nif_init_name = [] allocator = [] nif_version_2_14 = ["rustler_sys/nif_version_2_14"] @@ -23,7 +23,7 @@ serde = ["dep:serde"] [dependencies] inventory = "0.3" -rustler_codegen = { path = "../rustler_codegen", version = "0.33.0", optional = true} +rustler_codegen = { path = "../rustler_codegen", version = "0.33.0" } rustler_sys = { path = "../rustler_sys", version = "~2.4.1" } num-bigint = { version = "0.4", optional = true } serde = { version = "1", optional = true } diff --git a/rustler/src/lib.rs b/rustler/src/lib.rs index 8166211f..ba3ec239 100644 --- a/rustler/src/lib.rs +++ b/rustler/src/lib.rs @@ -71,7 +71,6 @@ pub use nif::Nif; pub type NifResult = Result; -#[cfg(feature = "derive")] pub use rustler_codegen::{ init, nif, NifException, NifMap, NifRecord, NifStruct, NifTaggedEnum, NifTuple, NifUnitEnum, NifUntaggedEnum, Resource,