From 8a25089e5be7a65177f3842f3790bb9632ecfae8 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Tue, 9 Jan 2024 11:04:09 +0100 Subject: [PATCH] Use SerdeTerm for the 'readme' example --- rustler_tests/native/rustler_serde_test/src/lib.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/rustler_tests/native/rustler_serde_test/src/lib.rs b/rustler_tests/native/rustler_serde_test/src/lib.rs index e25bc01e..957be7c4 100644 --- a/rustler_tests/native/rustler_serde_test/src/lib.rs +++ b/rustler_tests/native/rustler_serde_test/src/lib.rs @@ -10,9 +10,8 @@ mod test; mod types; use crate::types::Animal; -use rustler::serde::{atoms, from_term, to_term, Deserializer, Error, Serializer}; -use rustler::SerdeTerm; -use rustler::{types::tuple, Encoder, Env, NifResult, Term}; +use rustler::serde::{atoms, Deserializer, Error, Serializer}; +use rustler::{types::tuple, Encoder, Env, NifResult, SerdeTerm, Term}; init! { "Elixir.SerdeRustlerTests", @@ -35,9 +34,9 @@ init! { /// Implements the README example. #[nif] -pub fn readme<'a>(env: Env<'a>, SerdeTerm(animal): SerdeTerm) -> NifResult> { +pub fn readme(SerdeTerm(animal): SerdeTerm) -> SerdeTerm { // println!("\n deserialized animal from README example: {:?}", animal); - to_term(env, animal).map_err(|err| err.into()) + SerdeTerm(animal) } /// Deserializes anything from an Elixir term and subsequently serializes the result back into an Elixir term, returning it.