19 ms·
Announcing Rust 1.35.0
- firethief 7y ago> Fn* closure traits implemented for Box<dyn Fn* > This threw me for a minute. Function pointers not using * is confusing enough without using glob syntax to talk about function types!
- Arnavion 7y agoYour comment was also confusing until I reached your parenthetical, because `+` is used for separating trait bounds :)
- firethief 7y agoYeah, I moved it to the top. Funny how I can't talk about the character being too overloaded because it has another meaning to the forum... Edit: the parent comment was replying to an earlier version of my comment, in which I used + because I didn't know that * could be kind-of escaped by putting a space after it
- tomjakubowski 7y agoWell, there is always: *mut fn(T, ...) -> U
- firethief 7y agoUnless you are intentionally bringing up pointers to function pointers, this is exactly the confusion I'm talking about :)
- ChrisSD 7y agoUse four spaces at the beginning of the line *
- firethief 7y agoThat breaks mobile. I get a scrollable area with no scrollbars, so the content just looks clipped.
- ChrisSD 7y agoWhich is why I used short lines.
- firethief 7y agoYeah, that's fine for your comment, but what I want to say isn't the same as what you said. I'm quoting a heading; it would be weird to break it in half, but it's too wide to display correctly even on my tablet.
- pcr910303 7y agoMaybe a cross-browsing bug?̊̈ I’ve never seen a browser that doesn’t scroll horizontally in mobile. In particular, I’ve used HN with iOS 12.2 Webkit and Android Google Chrome Evergreen and Chromium based browsers... Maybe a bug in Android Firefox?̊̈ (Or the browser you’re using?̊̈)
- deleted 7y ago[deleted]
- chc 7y agoIt should work as long as there's a space after the asterisk: > Fn* closure traits implemented for Box<dyn Fn* > This threw me for a minute. Function pointers not using * is confusing enough without using glob syntax to talk about function types!
- faryang1111 7y agoI no longer care about Rust anymore because of their lang team's await syntax decision process. It seems the team only cares about satisfying themselves rather than listening to the community's concern. Whenever users spoke about problems proposed by the team, they simply dismissed them saying the concern doesn't contain any new information. With this lang team, I think Rust is going to die quickly. It doesn't worth investment to learn it.
- Buttons840 7y ago“There are only two kinds of languages: the ones people complain about and the ones nobody uses.”
- kbenson 7y agoEvery language gains warts as features are added (or no features are added and it gets left behind and more of a pain to use). It's impossible to always make the right decision, and sometimes there is no right decision as conflicting needs war. If you're looking for a language without warts, good luck.
- steveklabnik 7y agoFor anyone playing along at home, when the async/await RFC was accepted, it left the final syntax of "await" to be decided before stabilization. That was a little over a year ago. There was some debate, but it's been under pretty intense debate since at least November of last year. This has been the most discussed aspect of Rust ever. The tracking issue has 296 comments. There have been numerous threads on the internals forum, and recently, multiple threads on reddit per day. The team (which, I should note, I am not on) repeatedly asked for feedback, and read these threads, as well as participated in them. It's been going in circles for ages. There are a few options with the syntax, but there's no clear standout winner; it really depends on how you weigh each pro and each con. At some point, though, it's the team's responsibility to decide. And so, on the sixth, they finally reached internal consensus. That's actually enough to just make the decision, but instead of just making the decision, they decided to go the extra mile, and say "here is our decision, and here are our reasons for reaching that decision. If you have something new to add to this incredibly long debate, please let us know, we'll be making the decision on the 23rd." : https://boats.gitlab.io/blog/post/await-decision/ https://boats.gitlab.io/blog/post/await-decision/ The internals thread on this post alone is 420 posts long: https://internals.rust-lang.org/t/a-final-proposal-for-await-syntax/10021 https://internals.rust-lang.org/t/a-final-proposal-for-await... So yes, there are some vocal people who preferred a different syntax than the one that was chosen. Heck, I actually mostly prefer a different syntax. But at some point, a decision has to be made. Some people are not going to be happy with any decision. That's just how it is. It's not about "not listening to the concerns"; the concerns were listened to, but in the end, a different decision than (apparently) your preferred one was made. That's just how it goes sometimes. There are people who are equally passionate about this that would have been just as mad as you are now had the decision gone your way. (I personally still wouldn't have made the call they did, but the call is reasonable. I've written code using it, and it's totally fine. I understand why the decision was made. We'll just have to see!)
- jakobdabo 7y agoComing from C/C++. Is working with the online package manager (Cargo?) mandatory? Or is there a sustainable way of working/developing with Rust while completely offline? I'd like to start a project, manually import libraries (downloaded manually, no dependency hell), read documentation, etc. Is it possible?
- steveklabnik 7y agoCargo can work offline. It’s a requirement of the Firefox and Debian build systems, for example. You can also use rustc without cargo if you really want, but Cargo is really good, so I don’t particularly recommend it.
- mrbonner 7y agoDoes that mean it only needs internet for the first build. And then, subsequent builds won’t need internet connection (if I don’t add new dependencies, of course), kind of like Maven?
- sanxiyn 7y agoNo, you can do everything, including the first build, offline.
- mrbonner 7y agoSorry, I should’ve been clearer: I need cargo to be online the 1st time so that it could resolve my dependencies for me online the 1st time because I don’t want to setup local repos and stuff. Thanks
- pitaj 7y agoIf you use dependencies from crates.io or other online sources, then yes you'd need to download those somehow. But that can be done separately, on an entirely different computer if you wanted.
- 7y ago
- haberman 7y agoComing from C++, this always throws me a bit: if (0..=10).contains(&5) { I assume we are taking a ref to "5" (and not passing by value) because "Range" is a generic type that might be too big to want to copy (or it may not be copyable at all). But taking a reference to a number for a simple operation like this feels... weird. It makes me worry that Rust is going to be passing around pointers to some stack-allocated "5", but I hope that Rust is actually much smarter than that?
- steveklabnik 7y agoThe optimizer should take care of that, yeah. The ABI isn’t defined so it can re-write stuff. And inlining, all that fun stuff.
- haberman 7y agoWill the calling convention pass this by value even if it isn't inlined? My hope is that the ABI would systematically decide: "passing a const ref to a type that fits in a machine word is silly, so we never do that."
- steveklabnik 7y agoI think so, but am not sure. The spec answer is “who knows” because it’s not defined, but practically I’m not 100% sure if the compiler does it always today.
- comex 7y agoNo, it never does that optimization: https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=cad24b5465a47cd4ae57cd0375979b31 https://play.rust-lang.org/?version=stable&mode=release&edit... (see assembly output) Edit 2: I lied: Rust doesn't perform such an optimization but LLVM does, -argpromote. But it only works if the callee is compiled in the same LLVM module as the caller (or with non-thin LTO), and is not visible outside that module. And since it has to respect pointer identity, it only works in a subset of cases. Original post: It arguably cannot, because you can cast the reference to a raw pointer and compare it to other pointers, though I don't think there's been a proper discussion on whether or not references are guaranteed to preserve pointer identity. Edit 1: However, Rust's compilation model does theoretically allow the compiler to modify a function's ABI based on its implementation, at least in some cases, so it could theoretically perform the optimization only when calling functions which it knows don't care about pointer identity. That would avoid violating the aforementioned guarantee that may or may not exist, but it would be less reliable, as the compiler's analysis would inevitably lose track of some pointer values and treat them as escaping, thus potentially identity-sensitive, when they're actually not.
- Shoop 7y agoThis update comes with a new version of rustup which has much faster updating, especially on windows [0]. If you'd like to experience this performance improvements, run `rustup self update` before your upgrade! [0] https://www.reddit.com/r/rust/comments/brtec1/rustup_1183_released/eogpfgr/ https://www.reddit.com/r/rust/comments/brtec1/rustup_1183_re...
- seeekr 7y agoNote for others also unsure of this: `rustup update` also does the self-update step, only after it first updates the toolchains.
- Shoop 7y agoNote that there is an open issue to perform the self-update before the update: [0]. Could be a good first patch for someone looking to contribute :) [0] https://github.com/rust-lang/rustup.rs/issues/1838 https://github.com/rust-lang/rustup.rs/issues/1838
- Paul-ish 7y agoAre there examples of RefMut::map_split? It seems pretty useful if it does what I think it does.
- comex 7y agoThe nightly version of the docs properly document that method, including an example: https://doc.rust-lang.org/nightly/std/cell/struct.RefMut.html#method.map_split https://doc.rust-lang.org/nightly/std/cell/struct.RefMut.htm...
- Arnavion 7y agoIf you click the link you will be taken to the docs page. You have to then click the `+` next to the function name to expand it and show the function docs, which includes an example.
- ridiculous_fish 7y agoRangeInclusive is an interesting API: 1. How does this handle ranges whose length is larger than can be represented in an integer? 2. How does iterating a range work for floats? It looks like it just adds one [1], won't this mean that it will loop forever if the next representable float is +2? 1: https://doc.rust-lang.org/src/core/iter/range.rs.html#297 https://doc.rust-lang.org/src/core/iter/range.rs.html#297
- comex 7y ago1. It doesn't. 2. The Iterator implementation for RangeInclusive requires the underlying type to implement Step [1], which floats do not. So you can't iterate over a range of floats (although you can still construct one). [1] https://doc.rust-lang.org/nightly/std/iter/trait.Step.html https://doc.rust-lang.org/nightly/std/iter/trait.Step.html
- ridiculous_fish 7y agoWhat do you mean by "it doesn't?" For example say I construct a range [INT_MIN, INT_MAX] which should have a length of 2^32. Am I prohibited from constructing this range?
- comex 7y agoI misinterpreted your comment; I thought you meant ranges that were so large they couldn't fit in any integer type (presumably of floats). But actually, it's weirder than I thought. RangeInclusive doesn't have an inherent len() method, but one is provided by the ExactSizeIterator trait, which is implemented only when the underlying type is i8, u8, i16, or u16. len() always returns usize, regardless of the original type; thus I believe the reason for that particular list of types is that usize is only guaranteed to be at least 16 bits. But I'm not sure why it's not also implemented for RangeInclusive<usize> and RangeInclusive<isize>...
- ridiculous_fish 7y agoNice, thanks for the complete answer. It's a highly principled (and perhaps frustrating) design, in keeping with Rust's ethos. By way of comparison, Swift overflows and returns a length of 0. Oh well.
- randyrand 7y agoJust an idea, instead of printing: [src/main.rs:4] x == 1 = false [src/main.rs:9] print this: [src/main.rs:4] dbg!( x == 1 ) = false [src/main.rs:9] dbg! Easier to filter just your debug messages.