rj00a / evenio

An event-driven Entity Component System
MIT License
132 stars 14 forks source link

Consider `Deref`/`DerefMut` support for `Single` #39

Closed andrewgazelka closed 5 months ago

andrewgazelka commented 5 months ago

I know Single is not a smart pointer, but it effectively acts like one—maybe?

I don't know. I know many people hate Deref and DerefMut for anything that isn't a smart pointer, but Single<T> is just a "pointer" to T stored in evenio.

Related Work

Json<T> in axum impls Deref and DerefMut

https://docs.rs/axum/latest/axum/struct.Json.html

rj00a commented 5 months ago

Sounds reasonable. The public .0 field of Single could interfere with deref coercion but other than that it seems fine. Should do it for TrySingle as well for parity.