owned this note
owned this note
Published
Linked with GitHub
# object type unsoundness
## `boluo-core 0.4.1`
also affects
- `boluo 0.5.3`
`(dyn AnyService<Req, Error = Err, Response = Res> + 'static): AnyService<Req>`
```rust
pub trait Service<Req>: Send + Sync {
type Response;
type Error;
// ...
}
trait AnyService<Req>: Send + Sync {
type Response;
type Error;
// ...
}
impl<S, Req> AnyService<Req> for S
where
S: Service<Req> + ?Sized,
{
type Response = S::Response;
type Error = S::Error;
// ...
}
```
## `daab 0.4.0`
`(dyn Builder<Rc<(dyn std::any::Any + 'static)>, Rc<(dyn std::any::Any + 'static)>, Artifact = test_dyn::ComplexNode, DynState = (), Err = never::Never> + 'static): rc::Builder`
```rust
pub trait Builder: Debug + 'static {
type Artifact : Debug + 'static;
type DynState : Debug + 'static;
type Err : Debug + 'static;
// ...
}
pub trait SimpleBuilder: Debug + 'static {
type Artifact : Debug + 'static;
// ...
}
impl<B: ?Sized + SimpleBuilder> Builder for B {
type Artifact = B::Artifact;
type DynState = ();
type Err = Never;
}
```
## `flipflop 0.1.0`
`(dyn AccumObj<Item = <A as Accum>::Item> + 'a): AccumObj`
```rust
pub trait AccumObj {
type Item;
}
impl<A: ?Sized + Accum> AccumObj for A {
type Item = A::Item;
}
pub trait Accum {
type Item;
// ...
}
```
## `thirtyfour 0.34.0`
Also affects
- https://github.com/Bubbler-4/gaboja `gaboja 0.4.1`
- https://github.com/DedicatedSoftwareDev/Web-bot-with-Rust
- https://github.com/JohannesNicholas/rust-chess-scraper
- https://github.com/Kirloxious/wordle-solver
- https://github.com/Sw1ndlers/ChromedriverManager `chromedriver-manager 0.3.5`
- https://github.com/benfrankel/find_a_job
- https://github.com/evshary/parse_sheet_from_weixin
`dyn ElementQueryFn<T, Fut = Pin<Box<dyn Future<Output = Result<T, WebDriverError>> + Send>>>: types::ElementQueryFn<T>`
```rust
pub trait ElementQueryFn<T>: Send + Sync {
type Fut: Future<Output = WebDriverResult<T>> + Send;
}
impl<T, Fut, Fun> ElementQueryFn<T> for Fun
where
Fun: Fn(WebElement) -> Fut + Send + Sync + ?Sized,
Fut: Future<Output = WebDriverResult<T>> + Send,
{
type Fut = Fut;
}
```
`dyn ElementQueryFn<T>` does not implement `Fn(WebElement)`
## `transmutter`
Oh look at me, I am so funny, publishing a crate for safe transmute
```rust
pub trait Transmutter<U> {
type Target;
}
impl<T: ?Sized, U> Transmutter<U> for T {
type Target = U;
}
fn transmutter<T: ?Sized, U>(source: <T as Transmutter<U>>::Target) -> U {
source
}
pub fn transmutte<T, U>(value: T) -> U {
transmutter::<dyn Transmutter<U, Target = T>, U>(value)
}
```
## `hooks-yew` / `hooks`
oh no, a lifetime error on a call to `erased_use_hook` for `dyn for<'a> ErasedHook<(&'a Props,), ValueGat = dyn for<'hook> ValueGat<'hook, Value = VNode>>`
https://github.com/frender-rs/hooks/blob/7d4127130725e1eb347c05d6460a15dd59c89670/packages/hooks-core/src/erased_hook.rs
the underlying pattern is as follows:
```rust
trait Trait<T> {
fn method(&self);
}
trait Erased<T> {
type Assoc;
fn erased(&self);
}
impl<T> Trait<T> for dyn Erased<T, Assoc = ()> {
fn method(&self) {
self.erased();
}
}
impl<T, H: Trait<T> + ?Sized> Erased<T> for H {
type Assoc = ();
fn erased(&self) {
self.method();
}
}
fn break_me(hr: Box<dyn for<'a> Erased<&'a (), Assoc = ()>>) {
// `hr` implements `for<'a> Erased<&'a ()>` via the builtin impl
//
// using the indirection via `dyn Erased<T>: Trait<T>` forces
// `'a` to not be higher-ranked.
hr.erased();
}
```