linera_base/
dyn_convert.rs

1// Copyright (c) Zefchain Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4/*!
5Object-safe conversion traits.
6*/
7
8/// An object-safe version of `std::convert::Into`.
9pub trait DynInto<To> {
10    /// Converts a boxed object into the target type.
11    fn into_box(self: Box<Self>) -> To;
12}
13
14impl<To, From: Into<To>> DynInto<To> for From {
15    fn into_box(self: Box<From>) -> To {
16        (*self).into()
17    }
18}