CandyMachine program has this function, which is used extensively in the program code:
pub fn cmp_pubkeys(a: &Pubkey, b: &Pubkey) -> bool {
sol_memcmp(a.as_ref(), b.as_ref(), PUBKEY_BYTES) == 0
}
However, I do not see, how this is different from simply using Eq
trait.