You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is like Clojure's doto it seems. I'm not sure it's a good idea to assign to it every time. That would basically mean the underlying calls would need to be chainable, which is not always true.
Before adding such a macro by default, I would like someone to demonstrate places in real Rust code that could benefit from it. An operator that is useful according to Dart's idioms is not automatically useful in Rust. Until then, this issue should not be re-opened.
Before adding such a macro by default, I would like someone to demonstrate
places in real Rust code that could benefit from it. An operator that is
useful according to Dart's idioms is not automatically useful in Rust.
Until then, this issue should not be re-opened.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/6679#issuecomment-43461647
.
Before adding such a macro by default, I would like someone to
demonstrate places in real Rust code that could benefit from it. An
operator that is useful according to Dart's idioms is not automatically
useful in Rust. Until then, this issue should not be re-opened.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/6679#issuecomment-43461647
.
Method cascades can currently be done with the cascade crate. Highly critical if you're working with certain types of APIs, such as constructing GTK widgets in gtk-rs. System76 uses it in all of their GTK applications.
Activity
mstewartgallus commentedon May 22, 2013
Is it possible to do this with a macro? It could have a syntax like:
And that would desugar to something like
Something along these lines could be useful to implement.
metajack commentedon May 22, 2013
This is like Clojure's
doto
it seems. I'm not sure it's a good idea to assign toit
every time. That would basically mean the underlying calls would need to be chainable, which is not always true.bstrie commentedon May 22, 2013
It's a neat concept, and I think I actually prefer the look of it to method chaining, but I'm not sure if it's really necessary for Rust.
emberian commentedon Aug 5, 2013
This would be pretty cool indeed, as a syntax extension.
Aatch commentedon Mar 23, 2014
If anybody is still interested in this, an official RFC should be filed. https://github.com/rust-lang/rfcs/blob/master/active/0001-rfc-process.md
ariasuni commentedon May 18, 2014
@huonw has implemented cascade operator with a macro that can be used as follow:
I think it’s a great addition to the language compared to the quantity of code to merge, so please re-open.
bstrie commentedon May 19, 2014
Before adding such a macro by default, I would like someone to demonstrate places in real Rust code that could benefit from it. An operator that is useful according to Dart's idioms is not automatically useful in Rust. Until then, this issue should not be re-opened.
emberian commentedon May 19, 2014
I've used a similar macro called
with
(emulating VB.NET'swith
statement), but it was only for a toy -- I found no uses for it in real
code.
On Sun, May 18, 2014 at 7:24 PM, Ben Striegel notifications@github.comwrote:
http://octayn.net/
emberian commentedon May 19, 2014
(Especially since we have functional record update)
On Sun, May 18, 2014 at 7:35 PM, Corey Richardson corey@octayn.net wrote:
http://octayn.net/
ariasuni commentedon May 19, 2014
I don’t link to lines where the use of cascade operator would me more verbose than without it.
https://github.com/mozilla/rust/blob/master/src/librustc/back/archive.rs#L59
https://github.com/mozilla/rust/blob/master/src/librustc/back/rpath.rs#L184
https://github.com/mozilla/rust/blob/master/src/librustc/middle/liveness.rs#L827
https://github.com/mozilla/rust/blob/master/src/librustc/middle/liveness.rs#L1026
https://github.com/mozilla/rust/blob/master/src/librustc/middle/liveness.rs#L1374
https://github.com/mozilla/rust/blob/master/src/librustc/middle/resolve.rs#L961
https://github.com/mozilla/rust/blob/master/src/librustc/middle/resolve.rs#L1951
https://github.com/mozilla/rust/blob/master/src/librustc/middle/resolve.rs#L2398
https://github.com/mozilla/rust/blob/master/src/librustc/front/feature_gate.rs#L372
https://github.com/mozilla/rust/blob/master/src/librustc/metadata/filesearch.rs#L148
https://github.com/mozilla/rust/blob/master/src/librustc/metadata/creader.rs#L320
https://github.com/mozilla/rust/blob/master/src/librustc/metadata/creader.rs#L420
https://github.com/mozilla/rust/blob/master/src/librustc/metadata/loader.rs#L376
I guess it might not be useful to use cascade! in every code I quote though.
dharmatech commentedon May 19, 2014
Candidates for method cascade usage in servo:
https://github.com/mozilla/servo/blob/master/src/components/gfx/render_context.rs#L56
https://github.com/mozilla/servo/blob/master/src/components/gfx/render_context.rs#L79
https://github.com/mozilla/servo/blob/master/src/components/gfx/render_context.rs#L256
dharmatech commentedon May 19, 2014
draw_push_clip as it currently is:
https://gist.github.com/dharmatech/ded09b46ff700697aef6
How it would look with built-in support for method cascades:
https://gist.github.com/dharmatech/16000fa777356ee74cbc
emberian commentedon May 19, 2014
It doesn't need to be built-in to use it. The macro can be defined anywhere.
On Mon, May 19, 2014 at 10:50 AM, dharmatech notifications@github.comwrote:
http://octayn.net/
dharmatech commentedon May 19, 2014
rust-http - handle_request - after
q3 - render - after
schmee commentedon May 20, 2014
@dharmatech That draw_push_clip example looks really, really nice. More readable, less noise.
cuzbog commentedon Apr 15, 2015
Any news on this?
mmstick commentedon Jan 16, 2019
Method cascades can currently be done with the cascade crate. Highly critical if you're working with certain types of APIs, such as constructing GTK widgets in gtk-rs. System76 uses it in all of their GTK applications.
Auto merge of rust-lang#6679 - flip1995:ra_setup_abs_path, r=Manishearth