concision_traits/tensor/
tensor_data.rs

1/*
2    Appellation: repr <module>
3    Created At: 2025.12.09:10:04:11
4    Contrib: @FL03
5*/
6use rspace_traits::RawSpace;
7
8pub trait RawTensorData: RawSpace {
9    private! {}
10}
11
12pub trait RawTensor<S, D, A>
13where
14    S: RawTensorData,
15{
16    type Cont<_S, _D, _A>
17    where
18        _D: ?Sized,
19        _S: RawTensorData<Elem = _A>;
20}
21/// A marker trait used to denote tensors that represent scalar values; more specifically, we
22/// consider _**any**_ type implementing the [`RawTensorData`] type where the `Elem` associated
23/// type is the implementor itself a scalar value.
24pub trait ScalarTensorData: RawTensorData<Elem = Self> {
25    private! {}
26}
27
28/*
29 ************* Implementations *************
30*/
31
32impl<T> ScalarTensorData for T
33where
34    T: RawTensorData<Elem = Self>,
35{
36    seal! {}
37}
38
39macro_rules! impl_scalar_tensor {
40    {$($T:ty),* $(,)?} => {
41        $(
42            impl RawTensorData for $T {
43                seal! {}
44            }
45        )*
46    };
47}
48
49impl_scalar_tensor! {
50    u8, u16, u32, u64, u128, usize,
51    i8, i16, i32, i64, i128, isize,
52    f32, f64,
53    bool, char
54}
55
56#[cfg(feature = "alloc")]
57impl RawTensorData for alloc::string::String {
58    seal! {}
59}