From fec7454ced4c182c7bdb750ad9837d0be5336eff Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Tue, 1 Aug 2023 11:11:46 +0300 Subject: [PATCH] chore: simply use FieldId::new because it contains id == 0 check --- lib/binding_rust/lib.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs index 917243b0..ae8e744d 100644 --- a/lib/binding_rust/lib.rs +++ b/lib/binding_rust/lib.rs @@ -334,11 +334,7 @@ impl Language { field_name.len() as u32, ) }; - if id == 0 { - None - } else { - Some(FieldId::new(id).unwrap()) - } + FieldId::new(id) } } @@ -1249,14 +1245,8 @@ impl<'a> TreeCursor<'a> { /// See also [field_name](TreeCursor::field_name). #[doc(alias = "ts_tree_cursor_current_field_id")] pub fn field_id(&self) -> Option { - unsafe { - let id = ffi::ts_tree_cursor_current_field_id(&self.0); - if id == 0 { - None - } else { - Some(FieldId::new(id).unwrap()) - } - } + let id = unsafe { ffi::ts_tree_cursor_current_field_id(&self.0) }; + FieldId::new(id) } /// Get the field name of this tree cursor's current node.