a1/column/
into.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use crate::{Column, RangeOrCell, A1};

#[allow(clippy::from_over_into)]
impl Into<RangeOrCell> for Column {
    fn into(self) -> RangeOrCell {
        RangeOrCell::ColumnRange {
            from: self,
            to: self,
        }
    }
}

#[allow(clippy::from_over_into)]
impl Into<A1> for Column {
    fn into(self) -> A1 {
        A1 {
            sheet_name: None,
            reference: self.into(),
        }
    }
}

#[cfg(test)]
mod tests {
    use crate::*;

    #[test]
    fn into_column() {
        assert_eq!(
            RangeOrCell::ColumnRange {
                from: Column::new(0),
                to: Column::new(0),
            },
            Column::new(0).into()
        );
    }

    #[test]
    fn into_a1() {
        assert_eq!(
            A1 {
                sheet_name: None,
                reference: RangeOrCell::ColumnRange {
                    from: Column::new(0),
                    to: Column::new(0),
                },
            },
            Column::new(0).into()
        );
    }
}