SorteKanin@feddit.dk to Rust@programming.dev · 8 days agoJust call clone (or alias) · baby stepssmallcultfollowing.comexternal-linkmessage-square5linkfedilinkarrow-up18arrow-down10
arrow-up18arrow-down1external-linkJust call clone (or alias) · baby stepssmallcultfollowing.comSorteKanin@feddit.dk to Rust@programming.dev · 8 days agomessage-square5linkfedilink
minus-square0t79JeIfK01RHyzo@lemmy.mllinkfedilinkEnglisharrow-up2·edit-25 days agoI like this solution more too, what about something like? code examples { spawn(async move { do_something_else_with( ^{ self.some_a.clone() }, ^{ self.some_a.clone() }, ^{ self.some_a.clone() }, ) }); } Which desugars to { let (a, b, c) = (self.some_a.clone(), self.some_a.clone(), self.some_a.clone()); spawn(async move { do_something_else_with(a, b, c) }); } Then have like 'super1: { 'super2: { spawn(async move { do_something_else_with( ^super1: { self.some_a.clone() }, ^super1: { self.some_a.clone() }, ^super1: { self.some_a.clone() }, ) }); } } Which desugars to 'super1: { let (a, b, c) = (self.some_a.clone(), self.some_a.clone(), self.some_a.clone()); 'super2: { spawn(async move { do_something_else_with(a, b, c) }); } } And finally, the harder to read 'super1: { 'super2: { spawn(async move { do_something_else_with( ^^{ self.some_a.clone() }, ^^{ self.some_a.clone() }, ^^{ self.some_a.clone() }, ) }); } } Which desugars to 'super1: { let (a, b, c) = (self.some_a.clone(), self.some_a.clone(), self.some_a.clone()); 'super2: { spawn(async move { do_something_else_with(a, b, c) }); } }
minus-squareSorteKanin@feddit.dkOPlinkfedilinkarrow-up2·7 days agoI like the idea of using block labels, but I don’t like the ^ symbol. There’s already precedent for using keywords before blocks, like with async. There’s also already super let in nightly I believe.
I like this solution more too, what about something like?
code examples
{ spawn(async move { do_something_else_with( ^{ self.some_a.clone() }, ^{ self.some_a.clone() }, ^{ self.some_a.clone() }, ) }); }Which desugars to
{ let (a, b, c) = (self.some_a.clone(), self.some_a.clone(), self.some_a.clone()); spawn(async move { do_something_else_with(a, b, c) }); }Then have like
'super1: { 'super2: { spawn(async move { do_something_else_with( ^super1: { self.some_a.clone() }, ^super1: { self.some_a.clone() }, ^super1: { self.some_a.clone() }, ) }); } }Which desugars to
'super1: { let (a, b, c) = (self.some_a.clone(), self.some_a.clone(), self.some_a.clone()); 'super2: { spawn(async move { do_something_else_with(a, b, c) }); } }And finally, the harder to read
'super1: { 'super2: { spawn(async move { do_something_else_with( ^^{ self.some_a.clone() }, ^^{ self.some_a.clone() }, ^^{ self.some_a.clone() }, ) }); } }Which desugars to
'super1: { let (a, b, c) = (self.some_a.clone(), self.some_a.clone(), self.some_a.clone()); 'super2: { spawn(async move { do_something_else_with(a, b, c) }); } }I like the idea of using block labels, but I don’t like the ^ symbol. There’s already precedent for using keywords before blocks, like with async. There’s also already super let in nightly I believe.