MCPcopy Create free account
hub / github.com/HFQR/xitca-web / try_downcast_to_bytes

Function try_downcast_to_bytes

http-encoding/src/coder.rs:300–308  ·  view source on GitHub ↗
(item: T)

Source from the content-addressed store, hash-verified

298}
299
300fn try_downcast_to_bytes<T: 'static>(item: T) -> Result<Bytes, T> {
301 use core::any::Any;
302
303 let item = &mut Some(item);
304 match (item as &mut dyn Any).downcast_mut::<Option<Bytes>>() {
305 Some(bytes) => Ok(bytes.take().unwrap()),
306 None => Err(item.take().unwrap()),
307 }
308}
309
310#[cfg(test)]
311mod test {

Callers 1

codeMethod · 0.70

Calls 1

takeMethod · 0.45

Tested by

no test coverage detected