Skip to content

Add geometry type for curve#98

Merged
utilForever merged 1 commit into
utilForever:mainfrom
nvphungdev:feat/curve-struct
May 20, 2026
Merged

Add geometry type for curve#98
utilForever merged 1 commit into
utilForever:mainfrom
nvphungdev:feat/curve-struct

Conversation

@nvphungdev
Copy link
Copy Markdown
Contributor

@nvphungdev nvphungdev commented May 17, 2026

What

Add a Curve geometry type to bracket-geometry, storing 2D control points and exposing basic accessors for construction, endpoints, length, and emptiness.

Why

Closes #93.

Validation

  • cargo check --all passed
  • cargo fmt --all -- --check passed
  • cargo test -p bracket-geometry passed: 99 unit tests and 7 doctests
  • cargo clippy -p bracket-geometry --all-targets -- -D warnings -A clippy::multiple-crate-versions passed
  • cargo check -p bracket-geometry --features serde passed
  • git diff --check passed

Notes:

  • cargo test --all could not complete locally because the machine ran out of disk while linking existing bracket-terminal examples (ld: write() failed, errno=28).
  • cargo clippy --workspace --all-targets -- -D warnings -A clippy::multiple-crate-versions currently stops on an existing lint in bracket-noise/src/fastnoise.rs:2777 (clippy::collapsible_else_if), before reaching this change as a workspace-wide pass.

Checklist

Required

  • cargo check --all passes
  • cargo fmt --all -- --check passes
  • cargo clippy --workspace --all-targets -- -D warnings -A clippy::multiple-crate-versions passes
  • cargo test --all passes
  • I linked the related issue (for example: Closes #123)

Functional Validation

  • Behavior related to this change was verified locally (if applicable)
  • Rendering/backend behavior was verified when runtime code changed (if applicable)
  • Algorithm behavior (pathfinding/FOV/noise/random) was verified when affected (if applicable)
  • I added or updated tests for changed behavior (if applicable)

Configuration & Docs

  • User-facing docs were updated (README.md, ARCHITECTURE.md, or relevant manual pages, if applicable)
  • New dependencies/configuration are documented (if applicable)
  • No sensitive values or credentials were introduced

If Applicable

  • Security impact considered (run cargo audit locally if needed)
  • Breaking behavior changes are clearly described in this PR

Summary by CodeRabbit

  • New Features

    • Added Curve as a new geometric primitive for representing 2D curves via control points
    • Flexible construction from collections and slices
    • Accessors for control point retrieval and basic curve properties
    • Optional serialization/deserialization when the serde feature is enabled
  • Documentation

    • README and crate docs updated with Curve usage examples and serde feature notes

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 958d40e5-5ce0-4614-8cd2-c0d0a621934f

📥 Commits

Reviewing files that changed from the base of the PR and between a4fbef1 and 6f2c7bb.

📒 Files selected for processing (4)
  • bracket-geometry/README.md
  • bracket-geometry/src/curve.rs
  • bracket-geometry/src/lib.rs
  • src/lib.rs
✅ Files skipped from review due to trivial changes (2)
  • src/lib.rs
  • bracket-geometry/README.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • bracket-geometry/src/lib.rs
  • bracket-geometry/src/curve.rs

📝 Walkthrough

Walkthrough

Adds a new Curve type (control points Vec) with constructors, accessors, From conversions, optional serde derives, and unit tests; wires the module into the crate and prelude; updates README and crate docs to document Curve and its serde support.

Changes

Curve Geometric Primitive

Layer / File(s) Summary
Curve type definition and API
bracket-geometry/src/curve.rs
Curve struct stores control points as Vec<Point>, provides constructor and query methods (len, is_empty, first, last, control_points), From<Vec<Point>> and From<&[Point]> implementations, conditional serde derives, and unit tests validating construction and access.
Module wiring and crate integration
bracket-geometry/src/lib.rs
Adds mod curve;, re-exports crate::curve::* via the crate prelude, and expands crate-level documentation to include curve plotting functionality.
User-facing documentation
bracket-geometry/README.md, src/lib.rs
README feature list now includes Curve; new "Curve" section with construction and endpoint-access example; serde feature docs updated to include Curve; root crate docs mention Curve among primitives.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • utilForever

Poem

A rabbit sketches curves with a hop and a dot,
Control points in a line, connecting each dot,
From slice or from vec, it leaps into place,
Prelude and docs cheer, serde joins the race,
Tests tuck it in snug — a smooth, curvy plot! 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add geometry type for curve' directly and clearly describes the main change: introducing a new Curve geometry type to the bracket-geometry crate.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 17, 2026
Copy link
Copy Markdown
Owner

@utilForever utilForever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check my comments? Thanks.

Comment thread bracket-geometry/src/curve.rs Outdated
Comment thread bracket-geometry/src/curve.rs Outdated
@utilForever utilForever changed the title feat: add curve geometry type Add geometry type for Curve May 19, 2026
@utilForever utilForever changed the title Add geometry type for Curve Add geometry type for curve May 19, 2026
@nvphungdev
Copy link
Copy Markdown
Contributor Author

Addressed both review comments by removing the redundant assertions from the curve tests.

Checked locally with:

  • cargo fmt --check
  • cargo test -p bracket-geometry

Copy link
Copy Markdown
Owner

@utilForever utilForever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now. Thanks for your work! 🦖

@utilForever utilForever merged commit 1b90707 into utilForever:main May 20, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Curve 구조체 정의

2 participants