concision_data/
dataset.rs1use super::Records;
6
7#[derive(Clone, Copy, Default, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
10#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
11pub struct DatasetBase<U, V> {
12 pub records: U,
13 pub targets: V,
14}
15
16impl<U, V> DatasetBase<U, V> {
17 pub fn new(records: U, targets: V) -> Self {
18 Self { records, targets }
19 }
20
21 pub const fn records(&self) -> &U {
22 &self.records
23 }
24 #[inline]
25 pub const fn records_mut(&mut self) -> &mut U {
26 &mut self.records
27 }
28
29 pub const fn targets(&self) -> &V {
30 &self.targets
31 }
32 #[inline]
33 pub const fn targets_mut(&mut self) -> &mut V {
34 &mut self.targets
35 }
36}
37
38impl<U, V> core::fmt::Display for DatasetBase<U, V>
39where
40 U: core::fmt::Display,
41 V: core::fmt::Display,
42{
43 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
44 write!(
45 f,
46 "{{\n records: {},\n targets: {}\n}}",
47 self.records, self.targets
48 )
49 }
50}
51
52impl<U, V> Records for DatasetBase<U, V> {
53 type Inputs = U;
54 type Targets = V;
55
56 fn inputs(&self) -> &Self::Inputs {
57 &self.records
58 }
59
60 fn inputs_mut(&mut self) -> &mut Self::Inputs {
61 &mut self.records
62 }
63
64 fn targets(&self) -> &Self::Targets {
65 &self.targets
66 }
67
68 fn targets_mut(&mut self) -> &mut Self::Targets {
69 &mut self.targets
70 }
71}