fix(types): implement Default for SearchRequest by vibeyclaw · Pull Request #226 · memvid/memvid · GitHub
Skip to content

fix(types): implement Default for SearchRequest - #226

Open
vibeyclaw wants to merge 1 commit into
memvid:mainfrom
vibeyclaw:fix/search-request-default-impl
Open

vibeyclaw wants to merge 1 commit into
memvid:mainfrom
vibeyclaw:fix/search-request-default-impl

Conversation

@vibeyclaw

Copy link
Copy Markdown

Problem

The Quick Start example in README uses struct-update syntax when constructing a SearchRequest:

let response = mem.search(SearchRequest {
    query: "planning".into(),
    top_k: 10,
    snippet_chars: 200,
    ..Default::default()
})?;

However, SearchRequest does not implement Default, so this code fails to compile with:

error[E0277]: the trait bound `SearchRequest: Default` is not satisfied

Reported in #221.

Fix

Add an explicit Default implementation for SearchRequest with sensible values:

  • query: empty String (callers override via struct-update)
  • top_k: 10
  • snippet_chars: 200
  • all optional / flag fields: None / false / enum defaults

This makes the README Quick Start compile without changes, and gives library users the ergonomic struct-update pattern they already expect.

Testing

The change is purely additive — a new impl Default block. Existing code is unaffected. The fix can be verified with:

let _ = SearchRequest { query: "hello".into(), ..Default::default() };

The README Quick Start example uses struct-update syntax
(..Default::default()) when constructing a SearchRequest,
but the type had no Default implementation, causing a
compile error (E0277) for users following the guide.

Add an explicit Default impl with sensible values:
  - query: empty string (callers override with their query)
  - top_k: 10
  - snippet_chars: 200
  - all optional / flag fields: None / false / enum default

Fixes: memvid#221
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.

1 participant