sonic_rs/pointer/
from.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
use faststr::FastStr;

use crate::PointerNode;

impl From<usize> for PointerNode {
    fn from(value: usize) -> Self {
        PointerNode::Index(value)
    }
}

impl From<&usize> for PointerNode {
    fn from(value: &usize) -> Self {
        PointerNode::Index(*value)
    }
}

impl From<&str> for PointerNode {
    fn from(value: &str) -> Self {
        PointerNode::Key(FastStr::new(value))
    }
}

impl From<FastStr> for PointerNode {
    fn from(value: FastStr) -> Self {
        PointerNode::Key(value)
    }
}

impl From<&FastStr> for PointerNode {
    fn from(value: &FastStr) -> Self {
        PointerNode::Key(value.clone())
    }
}