refactor: Pass borrowed types when possible#2346
Open
jbencin-stacks wants to merge 1 commit intostx-labs:mainfrom
Open
refactor: Pass borrowed types when possible#2346jbencin-stacks wants to merge 1 commit intostx-labs:mainfrom
jbencin-stacks wants to merge 1 commit intostx-labs:mainfrom
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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
&Stringwith&strin 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
&PathBufwith&Pathin theinstall_resourcefunction, and addPathto 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Small refactoring PR to clean up function signatures and use borrowed types instead of owned types where possible. This includes:
Stringand&Stringwith&str&Vec<T>with&[T]PathBufwithPath