apple_quant_algorithmic/volume/
construction.rs1use std::fmt::Debug;
2
3use apple_quant_core::log::error;
4
5pub trait VolumeConstruct<
6 T,
7 E: Debug,
8> {
9 fn new_checked(
10 t: impl Into<T>,
11 ) -> Result<Self, E>
12 where
13 Self: Sized;
14
15 fn new_unchecked(
16 t: impl Into<T>,
17 ) -> Self;
18
19 fn new_unchecked_release(
20 t: impl Into<T>,
21 ) -> Self
22 where
23 Self: Sized,
24 {
25 #[cfg(debug_assertions)]
26 match Self::new_checked(t) {
27 Ok(
28 volume,
29 ) => volume,
30 Err(e) => {
31 error!("{e:?}");
32 panic!();
33 },
34 }
35
36 #[cfg(not(debug_assertions))]
37 Self::new_unchecked(t)
38 }
39}