The collections pass
List, HashMap and String rounded out together, a HashSet added, and memmove beside memcpy; chosen by the user on 2026-10-21.
- A method that needs more of the element than the container does is a trait’s, as
Sortalready was (18.70), since a method cannot bound its type’s parameter:Search<T>(contains,index_of) for aListofEqelements,Extend<T>(extend,insert_slice,fill) forCopyones, andEqandHashon theListitself. A missing bound says which trait and which bound. - Absence is a pointer, as
HashMap::get’s already was (§9.1):first()/last()return^T,nullon an empty list, soxs.last() or returnreads as a lookup does. - Looking up a
Stringkey bystris a trait implemented forHashMap<String, V>alone —StrKeys<V>:get_str,get_mut_str,contains_str,remove_str— andStrSetforHashSet<String>. Chosen over aBorrowtrait, which would be a promise nothing checks that two types hash alike, and over overloading, which 18.5 rules out (T-0043). HashSet<T: Hash + Eq>is aHashMap<T, bool>underneath: the same table, one byte a slot for values that say nothing.- A runtime
strreaches C through aString:let owned = String::from(name)thenowned.as_cstr(). NoCStringtype; theStringalready keeps a zero after its bytes. PassingString::from(name).as_cstr()straight to a call is fine, since theStringlives to the end of the statement; binding thatcstrwithletis not (T-0006). memmove(dst, src, bytes)joins the placement primitives (§14.3): an overlapping copy,unsafeasmemcpyis.Listshifts elements with it whenT::is_trivially_copyableand one at a time otherwise (T-0042).hash_combinerelies on plain+wrapping, which 18.63 promises; it is not rewritten withwrapping_add, which would imply plain+might not wrap (T-0044).
Two follow-ups, the same day (r68), from what writing this exposed, fixed at the user’s word (“fix the issues you found”):
- An operator reads through a reference to a number,
bool,char,stror enum (§5.2), as an argument already did:x > 2on a&i32. Aretainpredicate takes a&Tand compares it on nearly every line, so without this the new API was awkward to use (T-0079). - Keeping a view of a temporary is an error,
DZ0407(§6.5):let c = String::from(name).as_cstr()compiled and read freed memory. The view is followed back through receivers, fields, indexes and slices only, never into a call’s arguments, and a value that needs a drop is no view, soPath("a") / "b"is not one (T-0078).
