Skip to content

Commit

Permalink
cargo fmt all
Browse files Browse the repository at this point in the history
  • Loading branch information
uzushino committed Feb 19, 2024
1 parent a0ef15f commit 607d85f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
8 changes: 4 additions & 4 deletions examples/mnist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ fn main() {
.into_iter()
.map(|v| v as f32)
.collect::<Vec<_>>();
let v: [f32; 28*28] = img_to_vec.try_into().unwrap();

let v: [f32; 28 * 28] = img_to_vec.try_into().unwrap();
ann.add_item(v, None);

if i % 1_000 == 0 {
Expand All @@ -74,7 +74,7 @@ fn main() {
.map(|v| v as f32)
.collect::<Vec<_>>();

let v: [f32; 28*28] = img_to_vec.try_into().unwrap();
let v: [f32; 28 * 28] = img_to_vec.try_into().unwrap();
let (result, _distance) = ann.query(v, 1, None);
let actual = result
.into_iter()
Expand All @@ -89,4 +89,4 @@ fn main() {
println!("{}\n{}", trn, tst);
}
}
}
}
16 changes: 12 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use libc::{c_float, c_int, c_uint, c_void};
use std::ffi::CString;
use std::path::Path;
use libc::{c_float, c_int, c_uint, c_void};

pub enum Index {}

Expand Down Expand Up @@ -42,8 +42,8 @@ mod ffi {
}
}

pub struct Voyager<const N : usize> {
ix: *mut Index
pub struct Voyager<const N: usize> {
ix: *mut Index,
}

impl<const N: usize> Voyager<N> {
Expand All @@ -54,7 +54,9 @@ impl<const N: usize> Voyager<N> {
Voyager { ix: index }
}

pub const fn dimension() -> usize { N }
pub const fn dimension() -> usize {
N
}

pub fn add_item(&self, w: [f32; N], id: Option<u32>) {
let len = w.len();
Expand Down Expand Up @@ -116,6 +118,12 @@ impl<const N: usize> Drop for Voyager<N> {
}
}

impl<const N: usize> Default for Voyager<N> {
fn default() -> Self {
Self::new()
}
}

#[cfg(test)]
mod test {
use super::*;
Expand Down

0 comments on commit 607d85f

Please sign in to comment.