parent
3c4d260bfc
commit
4e04e825b5
100
src/chains.rs
100
src/chains.rs
@ -8,56 +8,56 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
/// Formatting of chained expressions, i.e. expressions which are chained by
|
//! Formatting of chained expressions, i.e. expressions which are chained by
|
||||||
/// dots: struct and enum field access, method calls, and try shorthand (?).
|
//! dots: struct and enum field access, method calls, and try shorthand (?).
|
||||||
///
|
//!
|
||||||
/// Instead of walking these subexpressions one-by-one, as is our usual strategy
|
//! Instead of walking these subexpressions one-by-one, as is our usual strategy
|
||||||
/// for expression formatting, we collect maximal sequences of these expressions
|
//! for expression formatting, we collect maximal sequences of these expressions
|
||||||
/// and handle them simultaneously.
|
//! and handle them simultaneously.
|
||||||
///
|
//!
|
||||||
/// Whenever possible, the entire chain is put on a single line. If that fails,
|
//! Whenever possible, the entire chain is put on a single line. If that fails,
|
||||||
/// we put each subexpression on a separate, much like the (default) function
|
//! we put each subexpression on a separate, much like the (default) function
|
||||||
/// argument function argument strategy.
|
//! argument function argument strategy.
|
||||||
///
|
//!
|
||||||
/// Depends on config options: `chain_indent` is the indent to use for
|
//! Depends on config options: `chain_indent` is the indent to use for
|
||||||
/// blocks in the parent/root/base of the chain (and the rest of the chain's
|
//! blocks in the parent/root/base of the chain (and the rest of the chain's
|
||||||
/// alignment).
|
//! alignment).
|
||||||
/// E.g., `let foo = { aaaa; bbb; ccc }.bar.baz();`, we would layout for the
|
//! E.g., `let foo = { aaaa; bbb; ccc }.bar.baz();`, we would layout for the
|
||||||
/// following values of `chain_indent`:
|
//! following values of `chain_indent`:
|
||||||
/// Block:
|
//! Block:
|
||||||
/// ```
|
//! ```
|
||||||
/// let foo = {
|
//! let foo = {
|
||||||
/// aaaa;
|
//! aaaa;
|
||||||
/// bbb;
|
//! bbb;
|
||||||
/// ccc
|
//! ccc
|
||||||
/// }.bar
|
//! }.bar
|
||||||
/// .baz();
|
//! .baz();
|
||||||
/// ```
|
//! ```
|
||||||
/// Visual:
|
//! Visual:
|
||||||
/// ```
|
//! ```
|
||||||
/// let foo = {
|
//! let foo = {
|
||||||
/// aaaa;
|
//! aaaa;
|
||||||
/// bbb;
|
//! bbb;
|
||||||
/// ccc
|
//! ccc
|
||||||
/// }
|
//! }
|
||||||
/// .bar
|
//! .bar
|
||||||
/// .baz();
|
//! .baz();
|
||||||
/// ```
|
//! ```
|
||||||
///
|
//!
|
||||||
/// If the first item in the chain is a block expression, we align the dots with
|
//! If the first item in the chain is a block expression, we align the dots with
|
||||||
/// the braces.
|
//! the braces.
|
||||||
/// Block:
|
//! Block:
|
||||||
/// ```
|
//! ```
|
||||||
/// let a = foo.bar
|
//! let a = foo.bar
|
||||||
/// .baz()
|
//! .baz()
|
||||||
/// .qux
|
//! .qux
|
||||||
/// ```
|
//! ```
|
||||||
/// Visual:
|
//! Visual:
|
||||||
/// ```
|
//! ```
|
||||||
/// let a = foo.bar
|
//! let a = foo.bar
|
||||||
/// .baz()
|
//! .baz()
|
||||||
/// .qux
|
//! .qux
|
||||||
/// ```
|
//! ```
|
||||||
|
|
||||||
use shape::Shape;
|
use shape::Shape;
|
||||||
use config::IndentStyle;
|
use config::IndentStyle;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user