-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add example for from_byte() documenation #15271
Conversation
/// # #![feature(globs)] | ||
/// # use std::str::*; | ||
/// # fn main() { | ||
/// let string = from_byte(66u8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use these in qualified form, for clarity. I.e. the example could be:
```rust
use std::str;
let string = str::from_byte(66u8);
assert_eq!(string.as_slice(), "B");
```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Huon. I hadn't thought of that approach. I'll redo it.
On 2014-06-30 07:27, Huon Wilson wrote:
In src/libcollections/str.rs:
@@ -106,6 +106,20 @@ pub fn from_utf8_owned(vv: Vec) -> Result<String, Vec> {
/// # Failure
///
/// Fails if invalid UTF-8
+///
+/// # Example
+///
+/// ```rust
+///
+/// # #![feature(globs)]
+/// # use std::str::*;
+/// # fn main() {
+/// let string = from_byte(66u8);Use these in qualified form, for clarity:
use std::str; let string = str::from_byte(66u8); assert_eq!(string.as_slice(), "B");Reply to this email directly or view it on GitHub [1].
Links:
[1] https://github.com/rust-lang/rust/pull/15271/files#r14345395
You can batch them up at whatever size you'd like. Smaller ones are easier to review. If you're going to be doing a lot, I'd say do three or four at a time. |
Made changes as per huonw's suggestions. Any idea why the CI Build is failing? |
It times out every once in a while. I restarted it for you. |
I'm working on adding examples to the API documentation. Should future pull requests include examples for more than one function? Or is this about the right size for a pull request?
Properly infer types with type casts This PR reenables `Expectation::Castable` (previous attempt at rust-lang#14104, reverted by rust-lang#14120) and implements type cast checks, which enable us to infer a bit more. Castable expectations are relatively weak -- they only influence the inference if we cannot infer the types by other means. Therefore, we need to defer possible type unification with the casted type until we type check all expressions of the body. This PR adds a struct and slots in `InferenceContext` for the deferred cast checks (c.f. [`CastCheck`] in `rustc_hir_typeck`). I only implemented the bits that affect the inference result. It should be possible to return type adjustments for well-formed casts and report diagnostics for invalid casts, but I'm leaving them for future work for now. Fixes rust-lang#11571 Fixes rust-lang#15246 [`CastCheck`]: https://github.com/rust-lang/rust/blob/da1d099f91ea387a2814a6244dd875a2048b486f/compiler/rustc_hir_typeck/src/cast.rs#L55
I'm working on adding examples to the API documentation. Should future pull requests include examples for more than one function? Or is this about the right size for a pull request?