Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 28, 2025
1 parent 6bbeae5 commit e7c11ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
10 changes: 6 additions & 4 deletions platform/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use std::path::PathBuf;
fn main() {
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let project_root = PathBuf::from(manifest_dir)
.parent().unwrap() // "platform/"
.parent().unwrap() // "maplibre-native/"
.parent()
.unwrap() // "platform/"
.parent()
.unwrap() // "maplibre-native/"
.to_path_buf();

let mut cmake_cfg = cmake::Config::new(&project_root);
Expand All @@ -26,6 +28,6 @@ fn main() {
// cxx build
let mut cxx = cxx_build::bridge("src/lib.rs");
cxx.include(project_root.join("include"))
.flag_if_supported("-std=c++20")
.compile("maplibre_rust_bindings");
.flag_if_supported("-std=c++20")
.compile("maplibre_rust_bindings");
}
14 changes: 7 additions & 7 deletions platform/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ mod ffi {

// We specify the C++ namespace and the free function name exactly.
// cxx can bind free functions directly if they have a compatible signature.
// The signature must match what's in log2.hpp:
// "uint32_t ceil_log2(uint64_t x);"
//
// We'll express that to Rust as (u64 -> u32).
pub fn ceil_log2(x: u64) -> u32;
// The signature must match what's in log2.hpp:
// "uint32_t ceil_log2(uint64_t x);"
//
// We'll express that to Rust as (u64 -> u32).
pub fn ceil_log2(x: u64) -> u32;
}
}

Expand All @@ -28,10 +28,10 @@ mod tests {
fn test_log2() {
let result = ceil_log2(1);
assert_eq!(result, 0, "log2(1) = 0 bits needed");

let result = ceil_log2(2);
assert_eq!(result, 1, "log2(2) = 1 bit needed");

let result = ceil_log2(3);
assert_eq!(result, 2, "log2(3) -> 2 bits needed");
}
Expand Down

0 comments on commit e7c11ad

Please sign in to comment.