TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Rust traits for developer friendly libraries

102 pointsby nercuryabout 10 years ago

4 comments

ndarilekabout 10 years ago
I&#x27;ve been using Scala for years and have been eying Rust for a while. Nice to see lots of the things I like from Scala carry over. In particular this seems like a less magical version of Scala implicits, which seem incredibly cool at first until you realize that a particular library or framework implements implicits for everything, and tracking down the source for a given function involves guessing the signature or chasing down an implicit implicit conversion chain that gets you to one.<p>One thing I&#x27;m not sure about though, the article talks about implementing the Into trait, then quickly segues over to From. When would I use Into, when From, and do they both lead to the same end (I.e. a function that takes Into&lt;Whatever&gt;?) I&#x27;ve looked at the docs for each, and maybe I just haven&#x27;t had enough coffee yet but the distinction isn&#x27;t too clear.
评论 #9600834 未加载
novocaineabout 10 years ago
I still have the scars from libraries implementing implicit conversions in c++.<p>The question is - for people reading the code at the call site, how easy is it to grep for what&#x27;s actually happening?<p>I guess this rust trait at least hangs off the geobox class, but I think I might prefer the explicit ctor for non write-only code.
评论 #9600879 未加载
jblowabout 10 years ago
This way of doing things sure sounds like it has massive performance implications.
评论 #9600493 未加载
评论 #9600596 未加载
jdubabout 10 years ago
Hmm. <i>Can</i> you...<p><pre><code> impl From&lt;T&gt; for GeoBox </code></pre> ... outside the module&#x2F;crate in which GeoBox is defined (as suggested at the end)?
评论 #9600789 未加载
评论 #9600797 未加载