-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The purpose of this macro is to further reduce the number of allocations which occur when dealing with formatting strings. This macro will perform all of the static analysis necessary to validate that a format string is safe, and then it will wrap up the "format string" into an opaque struct which can then be passed around. Two safe functions are added (write/format) which take this opaque argument structure, unwrap it, and then call the unsafe version of write/format (in an unsafe block). Other than these two functions, it is not intended for anyone to ever look inside this opaque struct. The macro looks a bit odd, but mostly because of rvalue lifetimes this is the only way for it to be safe that I know of. Example use-cases of this are: * third-party libraries can use the default formatting syntax without any forced allocations * the fail!() macro can avoid allocating the format string * the logging macros can avoid allocation any strings
- Loading branch information
1 parent
6216661
commit 9a5f95a
Showing
6 changed files
with
234 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
9a5f95a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from huonw
at alexcrichton@9a5f95a
9a5f95a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging alexcrichton/rust/format-args = 9a5f95a into auto
9a5f95a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alexcrichton/rust/format-args = 9a5f95a merged ok, testing candidate = 4825db4
9a5f95a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/1415
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/1418
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/524
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/524
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/1434
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/525
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/525
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/1434
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/525
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/525
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/606
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/1419
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/524
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/525
success: http://buildbot.rust-lang.org/builders/auto-bsd-64-opt/builds/1203
9a5f95a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = 4825db4