summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-06-22 18:59:34 -0400
committerMason Reed <mason@vector35.com>2025-07-02 01:56:54 -0400
commitcada23947c77320a7055dcb547cb7a6ea34267df (patch)
treef20dd4ae3c2a0800adfbb1580e5ac2180c6be3b6 /rust/src
parent619376a90c644e264c7b2930593b6116b0ed25a2 (diff)
[Rust] Remove redundant `Result` from `Project::folders`
Also make `Project::file_by_path` take a `Path`.
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/project.rs12
1 files changed, 5 insertions, 7 deletions
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<Array<ProjectFolder>, ()> {
+ pub fn folders(&self) -> Array<ProjectFolder> {
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<Ref<ProjectFile>> {
+ pub fn file_by_path(&self, path: &Path) -> Option<Ref<ProjectFile>> {
let path_raw = path.to_cstr();
let result =
unsafe { BNProjectGetFileByPathOnDisk(self.handle.as_ptr(), path_raw.as_ptr()) };