clients: replace lifetime-annotated Request with owned String field#100
clients: replace lifetime-annotated Request with owned String field#100ooloth wants to merge 2 commits into
Conversation
#67 `struct Request<'a> { query: &'a str }` forced all callers to satisfy a lifetime constraint, tying the struct's validity to the borrow duration of an external string. The struct is constructed and immediately serialized; it does not need to borrow — it should own. Replace the `&'a str` field with `String`, drop the lifetime parameter, and call `.to_string()` at the single construction site. The struct can now be stored, moved, and passed freely without lifetime annotations. Closes #67
There was a problem hiding this comment.
Pull request overview
Removes the lifetime parameter from the Request struct in clients/src/linear.rs by changing its query field from &'a str to an owned String, simplifying lifetime management at the cost of one allocation per call.
Changes:
- Replace
struct Request<'a> { query: &'a str }withstruct Request { query: String } - Update the single construction site to call
.to_string()on the query
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
CI failure is pre-existing and unrelated to this PR. The two failing tests (
Generated by Claude Code |
✅ What
&'a strwithStringin theRequeststruct inclients/src/linear.rs, removing its lifetime parameter entirely.to_string()at the single construction site🤔 Why
Requestforced callers to ensure the query string outlived the struct, adding hidden constraints that resist refactoring👩🔬 How to validate
clients/src/linear.rsand expectstruct Request { query: String }with no'alifetime parameterRequest {and expect the construction site to use.to_string()cargo checkfrom the workspace root and expect zero errors🔖 Related links
Requeststruct in linear.rs with ownedStringfield #67Closes #67
Generated by Claude Code