For my pallet I have defined a StorageMap in the storage that stores a tuple.

pub(super) type NameOf<T: Config> =
    StorageMap<_, Twox64Concat, T::AccountId, (Nickname<T>, BalanceOf<T>)>;

Using a custom struct:

#[derive(Encode, Decode, Default, TypeInfo, MaxEncodedLen, PartialEq, RuntimeDebug)]
pub struct Nickname<T: Config> {
    pub first: BoundedVec<u8, T::MaxLength>,
    pub last: Option<BoundedVec<u8, T::MaxLength>>,

I have found a problem when trying to do one of the unit tests. I want to check if value stored that is suppose to be None is None:

assert_eq!(<NameOf<Test>>::get(2), None);

But I am getting this error:

binary operation `==` cannot be applied to type `std::option::Option<(pallet::Nickname<Test>, u64)>`

If I only get the value of my struct to compare it (even that the unwrap() will panic):

assert_eq!(<NameOf<Test>>::get(2).unwrap().0, None);

I still get the same error, even that I have the PartialEq trait in the struct.

binary operation `==` cannot be applied to type `pallet::Nickname<Test>`

If I just print the value I can see is None:

println!("{:?}", <NameOf<Test>>::get(2));

How can I make this assert_eq?

1 Answer 1


The code will try to apply the PartialEq derive to the config trait T as well, which does not make sense.
You can derive PartialEqNoBound instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.