Skip to content

Commit

Permalink
vec -> array
Browse files Browse the repository at this point in the history
  • Loading branch information
CPunisher committed Aug 29, 2024
1 parent e774118 commit 28cc515
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/pointer/point.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use faststr::FastStr;

/// Represents a json pointer path. It can be created by [`pointer!`] macro.
pub type JsonPointer = Vec<PointerNode>;
pub type JsonPointer = [PointerNode];

/// Represents a node in a json pointer path.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
Expand Down Expand Up @@ -46,12 +46,10 @@ pub enum PointerNode {
#[macro_export]
macro_rules! pointer {
() => (
std::vec::Vec::<$crate::PointerNode>::new()
([] as [$crate::PointerNode; 0])
);
($($x:expr),+ $(,)?) => (
<[_]>::into_vec(
std::boxed::Box::new([$($crate::PointerNode::from($x)),+])
)
[$($crate::PointerNode::from($x)),+]
);
}

Expand All @@ -61,7 +59,7 @@ mod test {
fn test_json_pointer() {
let pointers = pointer![];
println!("{:?}", pointers);
let mut pointers = pointer![1, 2, 3, "foo", "bar"];
let mut pointers = pointer![1, 2, 3, "foo", "bar"].to_vec();
pointers.push(123.into());
println!("{:?}", pointers);
}
Expand Down

0 comments on commit 28cc515

Please sign in to comment.