From 003085beeec4a3d516dd859ee59aeccb3f16426f Mon Sep 17 00:00:00 2001 From: Fabian Freyer Date: Tue, 8 Feb 2022 22:17:59 +0100 Subject: rust: Move icon and name setter to TagType::create --- rust/src/binaryview.rs | 11 ++--------- rust/src/tags.rs | 11 +++++++++-- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'rust/src') diff --git a/rust/src/binaryview.rs b/rust/src/binaryview.rs index 15f3030c..00069c15 100644 --- a/rust/src/binaryview.rs +++ b/rust/src/binaryview.rs @@ -679,9 +679,7 @@ pub trait BinaryViewExt: BinaryViewBase { name: N, icon: I, ) -> Ref { - let tag_type = TagType::create(self.as_ref()); - tag_type.set_name(name); - tag_type.set_icon(icon); + let tag_type = TagType::create(self.as_ref(), name, icon); unsafe { BNAddTagType(self.as_ref().handle, tag_type.handle); } @@ -726,12 +724,7 @@ pub trait BinaryViewExt: BinaryViewBase { } } - fn create_tag( - &self, - t: &TagType, - data: S, - user: bool, - ) -> Ref { + fn create_tag(&self, t: &TagType, data: S, user: bool) -> Ref { let tag = Tag::new(t, data); unsafe { BNAddTag(self.as_ref().handle, tag.handle, user) } tag diff --git a/rust/src/tags.rs b/rust/src/tags.rs index eddcc5f0..ac66b279 100644 --- a/rust/src/tags.rs +++ b/rust/src/tags.rs @@ -83,8 +83,15 @@ impl TagType { Ref::new(Self { handle }) } - pub(crate) fn create(view: &BinaryView) -> Ref { - unsafe { Self::from_raw(BNCreateTagType(view.handle)) } + pub fn create( + view: &BinaryView, + name: N, + icon: I, + ) -> Ref { + let tag_type = unsafe { Self::from_raw(BNCreateTagType(view.handle)) }; + tag_type.set_name(name); + tag_type.set_icon(icon); + tag_type } pub fn id(&self) -> BnString { -- cgit v1.3.1