Add downcast_ref to AnyViewHandle

I use unsafe code to transmute an AnyViewHandle to a ViewHandle<T> when
the type matches. Because ViewHandle<T> is repr(transparent) to the
wrapped AnyViewHandle, this is safe.
This commit is contained in:
Nathan Sobo 2023-04-02 16:10:16 -06:00
parent 71cf6ec5ae
commit 138aa0492a
4 changed files with 15 additions and 12 deletions

View file

@ -1021,8 +1021,7 @@ mod tests {
.active_item()
.unwrap()
.as_any()
.clone()
.downcast::<Editor>()
.downcast_ref::<Editor>()
.unwrap()
.read(cx)
.title(cx),
@ -1058,8 +1057,7 @@ mod tests {
.active_item()
.unwrap()
.as_any()
.clone()
.downcast::<Editor>()
.downcast_ref::<Editor>()
.unwrap()
.read(cx)
.title(cx),
@ -1095,8 +1093,7 @@ mod tests {
.active_item()
.unwrap()
.as_any()
.clone()
.downcast::<Editor>()
.downcast_ref::<Editor>()
.unwrap()
.read(cx)
.title(cx),
@ -1146,8 +1143,7 @@ mod tests {
.active_item()
.unwrap()
.as_any()
.clone()
.downcast::<Editor>()
.downcast_ref::<Editor>()
.unwrap()
.read(cx)
.title(cx),