Closed nrc closed 9 years ago
Before:
fn main() {
return doughnutFryer
.start()
.then(|_| _frostingGlazer.start())
.then(|_| Future.wait([
_conveyorBelts.start(),
sprinkleSprinkler.start(),
sauceDripper.start()
]))
.catchError(cannotGetConveyorBeltRunning)
.then(|_| tellEveryoneDonutsAreJustAboutDone())
.then(|_| Future.wait([
croissantFactory.start(),
_giantBakingOvens.start(),
butterbutterer.start()
])
.catchError(_handleBakingFailures)
.timeout(scriptLoadingTimeout, _handleBakingFailures)
.catchError(cannotGetConveyorBeltRunning))
.catchError(cannotGetConveyorBeltRunning)
.then(|_| {
_logger.info("Let's eat!");
});
}
After:
fn main() {
return doughnutFryer
.start()
.then(|_| _frostingGlazer.start())
.then(|_| Future.wait([
_conveyorBelts.start(),
sprinkleSprinkler.start(),
sauceDripper.start()
]))
.catchError(cannotGetConveyorBeltRunning)
.then(|_| tellEveryoneDonutsAreJustAboutDone())
.then(|_| Future.wait([
croissantFactory.start(),
_giantBakingOvens.start(),
butterbutterer.start()
])
.catchError(_handleBakingFailures)
.timeout(scriptLoadingTimeout, _handleBakingFailures)
.catchError(cannotGetConveyorBeltRunning))
.catchError(cannotGetConveyorBeltRunning)
.then(|_| {
_logger.info("Let's eat!");
});
}
The stress would seem to be passed.
If we start with everything all on one line, what do we end up with?
Thanks for trying this out!
Before:
fn main() { return doughnutFryer.start() .then(|_| _frostingGlazer.start()) .then(|_| Future.wait([ _conveyorBelts.start(), sprinkleSprinkler.start(), sauceDripper.start() ])) .catchError(cannotGetConveyorBeltRunning) .then(|_| tellEveryoneDonutsAreJustAboutDone()) .then(|_| Future.wait([ croissantFactory.start(), _giantBakingOvens.start(), butterbutterer.start() ]) .catchError(_handleBakingFailures) .timeout(scriptLoadingTimeout, _handleBakingFailures) .catchError(cannotGetConveyorBeltRunning)) .catchError(cannotGetConveyorBeltRunning) .then(|_| { _logger.info("Let's eat!"); }); }
Output:
Rustfmt failed at /Users/alex/Documents/research/nri/code/nri/fmt.rs:2: line exceeded maximum length (sorry)
Ah, that's not so good. I bet we're bailing some where and just reprinting the original.
This should be fun to look in to!
Yeah, not sure where it bails in this one. There's no easy extern
to point at!
There's 3 things in here that we don't format yet:
After removing the return, and replacing the arrays by regular arguments, my branch produces this:
fn main() {
doughnutFryer.start()
.then(|_| _frostingGlazer.start())
.then(|_| {
Future.wait(_conveyorBelts.start(),
sprinkleSprinkler.start(),
sauceDripper.start())
})
.catchError(cannotGetConveyorBeltRunning)
.then(|_| tellEveryoneDonutsAreJustAboutDone())
.then(|_| {
Future.wait(croissantFactory.start(),
_giantBakingOvens.start(),
butterbutterer.start())
.catchError(_handleBakingFailures)
.timeout(scriptLoadingTimeout, _handleBakingFailures)
.catchError(cannotGetConveyorBeltRunning)
})
.catchError(cannotGetConveyorBeltRunning)
.then(|_| {
_logger.info("Let's eat!");
});
}
:+1:
Er, method calls?
Yea, the chainy kind a.b().c()
. We don't do those yet. I'm working on it, though: https://github.com/nrc/rustfmt/pull/216
Yeah, I thought we did method calls, could be wrong though.
Oh right, makes sense.
Filed #302 and #303
This seems to work! (with rustfmt e80080deb60e78e7a57be4d693ca8e96cb14a1b2
)
Before:
fn main() { return doughnutFryer.start() .then(|_| _frostingGlazer.start()) .then(|_| Future.wait([ _conveyorBelts.start(), sprinkleSprinkler.start(), sauceDripper.start() ])) .catchError(cannotGetConveyorBeltRunning) .then(|_| tellEveryoneDonutsAreJustAboutDone()) .then(|_| Future.wait([ croissantFactory.start(), _giantBakingOvens.start(), butterbutterer.start() ]) .catchError(_handleBakingFailures) .timeout(scriptLoadingTimeout, _handleBakingFailures) .catchError(cannotGetConveyorBeltRunning)) .catchError(cannotGetConveyorBeltRunning) .then(|_| { _logger.info("Let's eat!"); }); }
After:
fn main() {
return doughnutFryer.start()
.then(|_| _frostingGlazer.start())
.then(|_| {
Future.wait([_conveyorBelts.start(),
sprinkleSprinkler.start(),
sauceDripper.start()])
})
.catchError(cannotGetConveyorBeltRunning)
.then(|_| tellEveryoneDonutsAreJustAboutDone())
.then(|_| {
Future.wait([croissantFactory.start(),
_giantBakingOvens.start(),
butterbutterer.start()])
.catchError(_handleBakingFailures)
.timeout(scriptLoadingTimeout, _handleBakingFailures)
.catchError(cannotGetConveyorBeltRunning)
})
.catchError(cannotGetConveyorBeltRunning)
.then(|_| {
_logger.info("Let's eat!");
});
}
\o/ victory!
This is so close to being parsable Rust code:
Can we do this well?
from http://journal.stuffwithstuff.com/2015/09/08/the-hardest-program-ive-ever-written/