remove some unsafe code (#366)

This commit modifies the cache code to use Box::leak, eliminating the need for std::mem::transmute.
This commit is contained in:
Daniel Gulotta 2025-07-29 13:23:08 -07:00 committed by GitHub
parent d6c4d9e943
commit ce8cabc337
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 12 deletions

View file

@ -7,7 +7,7 @@ use plonky2::{
witness::{PartitionWitness, Witness},
},
plonk::circuit_data::CommonCircuitData,
util::serialization::{Buffer, IoResult, Read, Write},
util::serialization::{Buffer, IoError, IoResult, Read, Write},
};
/// Plonky2 generator that allows debugging values assigned to targets. This generator doesn't
@ -66,7 +66,7 @@ impl<F: RichField + Extendable<D>, const D: usize> SimpleGenerator<F, D> for Deb
let name_len = src.read_usize()?;
let mut name_buf = vec![0; name_len];
src.read_exact(&mut name_buf)?;
let name = unsafe { String::from_utf8_unchecked(name_buf) };
let name = String::from_utf8(name_buf).map_err(|_| IoError)?;
let xs = src.read_target_vec()?;
Ok(Self { name, xs })
}