I am trying to use a custom allocator, using the allocator API in Rust.
It seems Rust considers Vec<u8,CustomAllocator> and Vec<u8> as two distinct types.
let a: Vec<u8,CustomAllocator> = Vec::new_in(CustomAllocator);
for x in [1,2,3] { a.push(x) }
let b:Vec<u8> = vec![1,2,3];
assert_eq!(a,b);
It means that a simple comparison like the below won't compile:
error[E0277]: can't compare `Vec<u8, CustomAllocator>` with `Vec<u8>`
--> src/main.rs:37:5
|
37 | assert_eq!(a,b);
| ^^^^^^^^^^^^^^^ no implementation for `Vec<u8, CustomAllocator> == Vec<u8>`
|
= help: the trait `PartialEq<Vec<u8>>` is not implemented for `Vec<u8, CustomAllocator>`
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
I can't implement the trait, as I don't own either Vec or PartialEq.
In reality, and in the context of my implementation, I may compare both underlying slices. But I don't see how I can achieve this with the language...
Any clue appreciated!