This document provides guidelines for maintaining high-quality Rust code. These rules MUST be followed by all AI coding agents and contributors.
All code you write MUST be fully optimized.
"Fully optimized" includes:
I'm a Rust newbie, and one of the things that I've found frustrating is that the default docker build experience is extremely slow. As it downloads crates, then dependencies, then finally my app - I often get distracted, start doing something else, then come back several minutes later and forget what I was doing
Recently, I had the idea to make it a little better by combining multistage builds with some of the amazing features from BuildKit. Specifically, cache mounts, which let a build container cache directories for compilers & package managers. Here's a quick annotated before & after from a real app I encountered.
This is a standard enough multistage Dockerfile. Nothing seemingly terrible or great here - just a normal build stage, and a smaller runtime stage.
// Generate SSH key called "play_key" with the comment of "pwho"
ssh-keygen -o -a 100 -t ed25519 -f play_key -C "pwho"
If you want to set a passphrase (recommended), then do so; otherwise, just press enter twice when prompted for a passphrase.
| defaults write -g NSScrollViewRubberbanding -int 0 | |
| defaults write -g NSAutomaticWindowAnimationsEnabled -bool false | |
| defaults write -g NSScrollAnimationEnabled -bool false | |
| defaults write -g NSWindowResizeTime -float 0.001 | |
| defaults write -g QLPanelAnimationDuration -float 0 | |
| defaults write -g NSScrollViewRubberbanding -bool false | |
| defaults write -g NSDocumentRevisionsWindowTransformAnimation -bool false | |
| defaults write -g NSToolbarFullScreenAnimationDuration -float 0 | |
| defaults write -g NSBrowserColumnAnimationSpeedMultiplier -float 0 | |
| defaults write com.apple.dock autohide-time-modifier -float 0 |
| if __name__ == "__main__": | |
| reactor_args = {} | |
| def run_twisted_wsgi(): | |
| from twisted.internet import reactor | |
| from twisted.web.server import Site | |
| from twisted.web.wsgi import WSGIResource | |
| resource = WSGIResource(reactor, reactor.getThreadPool(), app) | |
| site = Site(resource) |