≈ the.bay.news

Why would `as_ref()` be required here rather than a reference?

The Rust Programming Language Forum
Why would `as_ref()` be required here rather than a reference?
After playing around with newtypes a bit, I'm curious about this use of the AsRef trait: impl PaliSearcher { pub fn new(index: &PaliIndex) -> Result<Self> { let reader = Self::reader(index.as_ref())?; let uid = index.uid_field()?; let contents = index.contents_field()?; let query_parser = QueryParser::for_index(index.as_ref(), vec![contents]); Ok(Self { reader, query_parser, uid, contents, }) ...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.