Skip to content

Commit 37ee9b9

Browse files
committed
allow buffer_downcast to downcast back to the original Buffer<T>
Signed-off-by: Teo Koon Peng <[email protected]>
1 parent 943ea33 commit 37ee9b9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/buffer/any_buffer.rs

+11
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,17 @@ impl<T: 'static + Send + Sync> AnyBufferAccessImpl<T> {
861861
})),
862862
);
863863

864+
// Allow downcasting back to the original Buffer<T>
865+
buffer_downcasts.insert(
866+
TypeId::of::<Buffer<T>>(),
867+
Box::leak(Box::new(|location| -> Box<dyn Any> {
868+
Box::new(Buffer::<T> {
869+
location,
870+
_ignore: Default::default(),
871+
})
872+
})),
873+
);
874+
864875
let mut key_downcasts: HashMap<_, KeyDowncastRef> = HashMap::new();
865876

866877
// Automatically register a downcast to AnyBufferKey

0 commit comments

Comments
 (0)