Structure of Vectors

For my code I need to define structure of vectors and here is how I define,

struct RedactDemo<'a, S: PrimeField>{
	document: &'a [S],
	redactor: &'a [S],
	redacted: &'a [S], 

}

Further

let document = (0..LEN).map(|_| None).collect::<Vec<_>>();
	let redactor = (0..LEN).map(|_| None).collect::<Vec<_>>();
	let redacted = (0..LEN).map(|_| None).collect::<Vec<_>>();
	let mut params = {
			let c = RedactDemo{
				document: &document,
				redactor: &redactor,
				redacted: &redacted,						
				};
		     generate_random_parameters::<Bls12,_,_>(c,&mut OsRng).unwrap()
		 };

I am referring to the code in bellman/mod.rs at main · zkcrypto/bellman · GitHub and bellman/mimc.rs at main · zkcrypto/bellman · GitHub to build my code but it keeps giving error that Option does not have trait PrimeField. I am sorry this might be really silly but I don't understand what other trait they are expecting us to use and why is it a problem to use PrimeField, as I am directly taking the structure from the code.

Thanks!!

Go to docs.rs. Find which crate implements PrimeField (I don't see it in bellman). The doc page for PrimeField will list all types that implement it. These are the only types that you can use.

In your case that Option::None doesn't seem to be a type that someone has implemented PrimeField for. Remember that Rust doens't have nullable types, so something like Option<i32> is a different type that is completely incompatible with i32.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.