From 9f8ffe016453446b950e3d348d3afa060c2503b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Muska=C5=82a?= Date: Wed, 3 Feb 2021 17:15:42 +0000 Subject: [PATCH] Implement Clone for TreeCursor Cloning was supported by the C library, but not exposed in Rust bindings --- lib/binding_rust/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs index 0b0097f9..1c2e79dd 100644 --- a/lib/binding_rust/lib.rs +++ b/lib/binding_rust/lib.rs @@ -1147,6 +1147,12 @@ impl<'a> TreeCursor<'a> { } } +impl<'a> Clone for TreeCursor<'a> { + fn clone(&self) -> Self { + TreeCursor(unsafe { ffi::ts_tree_cursor_copy(&self.0) }, PhantomData) + } +} + impl<'a> Drop for TreeCursor<'a> { fn drop(&mut self) { unsafe { ffi::ts_tree_cursor_delete(&mut self.0) }