Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add changelog entries for v0.22 #277

Merged
merged 4 commits into from
Feb 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 73 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Simple `Debug` impl for `rustler::Error`
- Support newtype and tuple structs for `NifTuple` and `NifRecord`
- `rustler::Error::Term` encoding an arbitrary boxed encoder, returning `{:error, term}`

### Fixed

- Compilation time of generated decoders has been reduced significantly.
- Fixed a segfault caused by `OwnedEnv::send_and_clear`

### Changes

- Renamed `Pid` to `LocalPid` to clarify that it can't point to a remote process
Expand All @@ -18,26 +29,83 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `resource_struct_init!` is now `rustler::resource!`
- New `rustler::atoms!` macro removed the `atom` prefix from the name:

```rs
```rust
//
// Before

//
rustler::rustler_atoms! {
atom ok;
atom error;
}

//
// After

//
rustler::atoms! {
ok,
error,
}
```

### Fixed
- NIF functions can be initialized with a simplified syntax:

```rust
//
// Before
//
rustler::rustler_export_nifs! {
"Elixir.Math",
[
("add", 2, add)
],
None
}

//
// After
//
rustler::init!("Elixir.Math", [add]);
```

* Compilation time of generated decoders has been reduced significantly.
- NIFs can be derived from regular functions, if the arguments implement `Decoder` and the return type implements `Encoder`:

```rust
//
// Before
//
fn add<'a>(env: Env<'a>, args: &[Term<'a>]) -> Result<Term<'a>, Error> {
let num1: i64 = args[0].decode()?;
let num2: i64 = args[1].decode()?;

Ok((atoms::ok(), num1 + num2).encode(env))
}

//
// After
//
#[rustler::nif]
fn add(a: i64, b: i64) -> i64 {
a + b
}
```

- `rustler::nif` exposes more options to configure a NIF were the NIF is defined:

```rust

#[rustler::nif(schedule = "DirtyCpu")]
pub fn dirty_cpu() -> Atom {
let duration = Duration::from_millis(100);
std::thread::sleep(duration);

atoms::ok()
}

#[rustler::nif(name = "my_add")]
fn add(a: i64, b: i64) -> i64 {
a + b
}
```

## [0.21.0] - 2019-09-07

Expand Down