Skip to content

refactor: Pass borrowed types when possible#2346

Open
jbencin-stacks wants to merge 1 commit intostx-labs:mainfrom
jbencin-stacks:refactor/pass-borrowed-types
Open

refactor: Pass borrowed types when possible#2346
jbencin-stacks wants to merge 1 commit intostx-labs:mainfrom
jbencin-stacks:refactor/pass-borrowed-types

Conversation

@jbencin-stacks
Copy link
Copy Markdown
Contributor

Description

Small refactoring PR to clean up function signatures and use borrowed types instead of owned types where possible. This includes:

  • Replace String and &String with &str
  • Replace &Vec<T> with &[T]
  • Replace PathBuf with Path

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
components/observer/src/event_handler/http.rs 0.00% 1 Missing ⚠️
components/observer/src/indexer/bitcoin/mod.rs 0.00% 1 Missing ⚠️
components/observer/src/indexer/stacks/mod.rs 0.00% 1 Missing ⚠️
components/stacks-codec/src/codec.rs 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors function signatures to use borrowed types instead of owned types, improving API ergonomics. The changes include replacing &String with &str, &Vec<T> with &[T], and &PathBuf with &Path across multiple components, specifically in codec operations, indexing logic, analysis passes, and the Jupyter kernel installation module.

Changes:

  • Replace &String with &str in StacksString validation methods (is_valid_string, is_printable, from_string)
  • Replace &Vec<T> with &[T] in slice parameters across indexer, analysis, and cache modules
  • Replace &PathBuf with &Path in the install_resource function, and add Path to imports

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.

Show a summary per file
File Description
components/stacks-codec/src/codec.rs Updated StacksString methods to accept &str instead of &String, improving ergonomics and reducing unnecessary allocations
components/observer/src/indexer/stacks/mod.rs Changed get_tx_description to accept slice &[&NewEvent] instead of &Vec<&NewEvent>
components/observer/src/indexer/bitcoin/mod.rs Updated try_parse_stacks_operation to accept slice parameter instead of vector reference
components/observer/src/event_handler/http.rs Simplified empty slice syntax from &vec![] to &[] in function call
components/clarity-repl/src/repl/interpreter.rs Changed run_analysis parameter to accept &[Annotation] slice
components/clarity-repl/src/analysis/ (multiple files) Updated analysis cache and lint checker structures and functions to use &[Annotation] slices instead of &Vec<Annotation>
components/clarity-jupyter-kernel/src/jupyter/install.rs Changed install_resource to accept &Path instead of &PathBuf, with corresponding import update

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants