Why does printing a pointer print the same thing as printing the dereferenced pointer?

Rust usually focuses on object value (i.e. the interesting part of the contents) rather than object identity (memory addresses). The implementation of Display for &T where T implements Display defers directly to the contents. Expanding that macro manually for the String implementation of Display: impl<‘a> Display for &’a String { fn fmt(&self, f: &mut Formatter) … Read more

Invoking struct function gives “cannot refer to unexported field or method”

From http://golang.org/ref/spec#Exported_identifiers: An identifier may be exported to permit access to it from another package. An identifier is exported if both: the first character of the identifier’s name is a Unicode upper case letter (Unicode class “Lu”); and the identifier is declared in the package block or it is a field name or method name. … Read more