提交 f2655e23 编写于 作者: S Steven Allen

Note that formatters should not return spurious errors.

Doing otherwise would break traits like `ToString`.
上级 e4dd785b
......@@ -166,8 +166,14 @@
//!
//! Additionally, the return value of this function is `fmt::Result` which is a
//! typedef to `Result<(), std::fmt::Error>`. Formatting implementations should
//! ensure that they return errors from `write!` correctly (propagating errors
//! upward).
//! ensure that they propagate errors from the `Formatter` (e.g., when calling
//! `write!`) however, they should never return errors spuriously. That is, a
//! formatting implementation must and may only return an error if the passed-in
//! `Formatter` returns an error. This is because, contrary to what the function
//! signature might suggest, string formatting is an infallible operation.
//! This function only returns a result because writing to the underlying stream
//! might fail and it must provide a way to propagate the fact that an error has
//! occurred back up the stack.
//!
//! An example of implementing the formatting traits would look
//! like:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册