Combining vectors

Hi,
So I have these lines of codes,

let hash_bits = multipack::bytes_to_bits_le(&hash);
let value_bits = multipack::bytes_to_bits_le(&value);

After I checked the function page sapling_crypto_ce::circuit::multipack::bytes_to_bits_le - Rust , I understand that the result is vector of booleans and since I need to combine them, I do following,

let inputs_bits = hash_bits.extend(value_bits.iter().cloned());
let inputs = multipack::compute_multipacking(&inputs_bits);

But I get an error

error[E0308]: mismatched types
  --> src/main.rs:46:47
   |
46 |     let inputs = multipack::compute_multipacking(&inputs_bits);
   |                                                  ^^^^^^^^^^^^ expected slice `[bool]`, found `()`
   |
   = note: expected reference `&[bool]`
              found reference `&()`


Similarly, later,

 // Expose the vector of 32 boolean variables as compact public inputs.
        multipack::pack_into_inputs(cs.namespace(|| "document-verify"), &hash_f)

I get similar error,

error[E0308]: mismatched types
   --> src/main.rs:169:73
    |
169 |         multipack::pack_into_inputs(cs.namespace(|| "document-verify"), &hash_f)
    |                                                                         ^^^^^^^ expected slice, found `()`
    |
    = note: expected reference `&[Boolean]`
               found reference `&()`

Any idea how I can fix them?

Thanks!

The extend method itself returns nothing. You probably need something like:

let mut hash_bits = multipack::bytes_to_bits_le(&hash);
let value_bits = multipack::bytes_to_bits_le(&value);
// Assuming you don't need `hash_bits` and `input_bits` to be different
hash_bits.extend(value_bits.iter().cloned());
let inputs = multipack::compute_multipacking(&hash_bits);

And depending on if you need value_bits later or not, you can probably replace this line:

hash_bits.extend(value_bits.iter().cloned());

With one of these:

// Consumes `value_bits`, you can't user it later
hash_bits.extend(value_bits);
// Same as `.cloned()` but advertises/helps assure that it is not costly
hash_bits.extend(value_bits.iter().copied());

Thanks I got it working!