calcopiritus,

In tip #3 I don’t see any benefit of doing impl AsRef<[T]> over &[T]

internetionals,
@internetionals@toot.community avatar

@calcopiritus @hatchet That way you can pass a reference or anything that can be turned into a reference as an argument. So the caller can supply a &T, Box<T>, Rc<T>, Arc<T>, … (I dont’t know if there is a blanket impl so that even T itself will work.

hatchet,

Well, actually I would tend to agree that &[T] is preferable to AsRef in most cases; all of the smart pointers you mentioned can also easily be turned into plain references. I probably could have chosen a better example.

pgsuper, (edited )

Nice job! I’d add that the target of the Rustdoc link shortcuts can be customized, in case they are not autodetected or point to an undesired location, like so:


<span style="color:#323232;">/// Use a [Tool]
</span><span style="color:#323232;">///
</span><span style="color:#323232;">/// [Tool]: lib::types::Tool
</span>

That will make the word Tool point to that type (note that the namespaces there - in lib::types::Tool - are relative to the current module / context, so you can use an imported name directly there too, for example).

ParanoidAndr0id,

Bookmarked :)

Sibbo,

These are actually nice, thanks!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • Ask_kbincafe
  • oklahoma
  • feritale
  • SuperSentai
  • KamenRider
  • All magazines