From cada23947c77320a7055dcb547cb7a6ea34267df Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Sun, 22 Jun 2025 18:59:34 -0400 Subject: [Rust] Remove redundant `Result` from `Project::folders` Also make `Project::file_by_path` take a `Path`. --- rust/src/project.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'rust/src/project.rs') diff --git a/rust/src/project.rs b/rust/src/project.rs index b6295f6b..e3159efc 100644 --- a/rust/src/project.rs +++ b/rust/src/project.rs @@ -3,6 +3,7 @@ pub mod folder; use std::ffi::c_void; use std::fmt::Debug; +use std::path::Path; use std::ptr::{null_mut, NonNull}; use std::time::{Duration, SystemTime, UNIX_EPOCH}; @@ -240,14 +241,11 @@ impl Project { } /// Get a list of folders in the project - pub fn folders(&self) -> Result, ()> { + pub fn folders(&self) -> Array { let mut count = 0; let result = unsafe { BNProjectGetFolders(self.handle.as_ptr(), &mut count) }; - if result.is_null() { - return Err(()); - } - - Ok(unsafe { Array::new(result, count, ()) }) + assert!(!result.is_null()); + unsafe { Array::new(result, count, ()) } } /// Retrieve a folder in the project by unique folder `id` @@ -569,7 +567,7 @@ impl Project { } /// Retrieve a file in the project by the `path` on disk - pub fn file_by_path(&self, path: &str) -> Option> { + pub fn file_by_path(&self, path: &Path) -> Option> { let path_raw = path.to_cstr(); let result = unsafe { BNProjectGetFileByPathOnDisk(self.handle.as_ptr(), path_raw.as_ptr()) }; -- cgit v1.3.1