Skip to content

Commit a6f71ba

Browse files
corybueckerCopilot
andauthored
feat!: migrate native extension from C to Rust (#44)
* feat!: migrate native extension from C to Rust Complete rewrite of the native extension using Rust and the Magnus crate instead of C. This maintains the same public API while providing better memory safety and modern tooling. - Replace all C source files with Rust implementation - Add Cargo workspace and build configuration - Update gem specification for Rust compilation - Modernize codebase with frozen string literals - Update CI pipeline to support Rust builds - Bump version to 2.0.0-pre for major release BREAKING CHANGE: Build system now requires Rust toolchain instead of C compiler * Update ext/ruby_native_statistics/src/lib.rs Co-authored-by: Copilot <[email protected]> * refactor: use slice-based helpers to reduce code duplication in variance/stdev functions - Add calculate_variance() and calculate_stdev() helper functions that work with slices - Eliminate duplicated variance calculation logic across var, stdev, varp, stdevp functions - Use population parameter to distinguish between sample and population statistics - Replace length == 0.0 checks with more idiomatic array.is_empty() - Maintain Vec usage only where necessary (median, percentile need sorting) --------- Co-authored-by: Copilot <[email protected]>
1 parent fd775d6 commit a6f71ba

26 files changed

+661
-443
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@ name: Test suite
33
on:
44
- push
55

6-
env:
7-
CI: true
8-
96
jobs:
107
run-tests:
118
name: Run tests
12-
runs-on: ubuntu-latest
139
strategy:
1410
matrix:
11+
os:
12+
- ubuntu-latest
13+
- macos-latest
1514
ruby:
16-
- 3.2.6
17-
- 3.3.7
18-
- 3.4.1
15+
- 3.2.8
16+
- 3.3.8
17+
- 3.4.4
18+
runs-on: ${{ matrix.os }}
1919
steps:
2020
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
2121
- uses: ruby/setup-ruby@a9bfc2ecf3dd40734a9418f89a7e9d484c32b990
2222
with:
2323
ruby-version: ${{ matrix.ruby }}
24-
- run: gem install bundler --version 2.6.3 --no-document
24+
- run: gem install bundler --version 2.7.0 --no-document
2525
- run: bundle
2626
- run: rake

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,7 @@ build-iPhoneSimulator/
5555
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
5656
# .rubocop-https?--*
5757

58-
*.bundle
58+
*.bundle
59+
60+
/ext/ruby_native_statistics/target
61+
/target

Cargo.lock

Lines changed: 347 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[workspace]
2+
members = ["./ext/ruby_native_statistics"]
3+
resolver = "3"

0 commit comments

Comments
 (0)