about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2017-08-11 10:20:21 +0200
committerGitHub <noreply@github.com>2017-08-11 10:20:21 +0200
commit03abb9d97fe72c929e7d767c278f1446dafdc6ba (patch)
treed37681ee19702812c9d1a2f10109c62837ba78df /src/rustllvm/RustWrapper.cpp
parente9d39094c9653c16a8412cbf750d9995a8003151 (diff)
parentfac6ce79e54a2d5bdbdc5157c645970a479e2fb1 (diff)
downloadrust-03abb9d97fe72c929e7d767c278f1446dafdc6ba.tar.gz
rust-03abb9d97fe72c929e7d767c278f1446dafdc6ba.zip
Rollup merge of #43721 - natboehm:patch-1, r=steveklabnik
Provide more explanation for Deref in String docs

While working on a different project I encountered a point of confusion where using `&String` to dereference a `String` into `&str` did not compile. I found the explanation of [String Deref](https://doc.rust-lang.org/std/string/struct.String.html#deref), thought that it matched what I was trying to do, and was confused as to why my program did not compile when the docs stated that it would work with 'any function which takes a `&str`'. At the bottom it is mentioned that this will 'generally' work, unless `String` is needed, but I found this statement confusing based on the previous claim of 'any'. Looking further into the docs I was able to find the function `as_str()` that works instead.

I thought it might be helpful to mention here deref coercion, an instance in which using `&String` does not work, to explain why it does not work, then direct users to a different option that should work in this instance. A user casually skimming the page will likely come to this explanation first, then find `as_str()` later, but be no the wiser as to what potentially went wrong.

r? @steveklabnik
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions