feat(doc): Fix positions of indices

This commit is contained in:
rhysd 2021-10-19 16:30:25 +09:00
parent 012f318c97
commit e666763acf

View file

@ -628,8 +628,8 @@ impl ArgMatches {
/// .short('o')
/// .takes_value(true))
/// .get_matches_from(vec!["myapp", "-f", "-o", "val"]);
/// // ARGV indices: ^0 ^1 ^2 ^3
/// // clap indices: ^1 ^3
/// // ARGV indices: ^0 ^1 ^2 ^3
/// // clap indices: ^1 ^3
///
/// assert_eq!(m.index_of("flag"), Some(1));
/// assert_eq!(m.index_of("option"), Some(3));
@ -646,8 +646,8 @@ impl ArgMatches {
/// .short('o')
/// .takes_value(true))
/// .get_matches_from(vec!["myapp", "-f", "-o=val"]);
/// // ARGV indices: ^0 ^1 ^2
/// // clap indices: ^1 ^3
/// // ARGV indices: ^0 ^1 ^2
/// // clap indices: ^1 ^3
///
/// assert_eq!(m.index_of("flag"), Some(1));
/// assert_eq!(m.index_of("option"), Some(3));
@ -669,11 +669,11 @@ impl ArgMatches {
/// .short('o')
/// .takes_value(true))
/// .get_matches_from(vec!["myapp", "-fzF", "-oval"]);
/// // ARGV indices: ^0 ^1 ^2
/// // clap indices: ^1,2,3 ^5
/// //
/// // clap sees the above as 'myapp -f -z -F -o val'
/// // ^0 ^1 ^2 ^3 ^4 ^5
/// // ARGV indices: ^0 ^1 ^2
/// // clap indices: ^1,2,3 ^5
/// //
/// // clap sees the above as 'myapp -f -z -F -o val'
/// // ^0 ^1 ^2 ^3 ^4 ^5
/// assert_eq!(m.index_of("flag"), Some(1));
/// assert_eq!(m.index_of("flag2"), Some(3));
/// assert_eq!(m.index_of("flag3"), Some(2));
@ -695,11 +695,11 @@ impl ArgMatches {
/// .short('o')
/// .takes_value(true))
/// .get_matches_from(vec!["myapp", "-fzFoval"]);
/// // ARGV indices: ^0 ^1
/// // clap indices: ^1,2,3^5
/// //
/// // clap sees the above as 'myapp -f -z -F -o val'
/// // ^0 ^1 ^2 ^3 ^4 ^5
/// // ARGV indices: ^0 ^1
/// // clap indices: ^1,2,3^5
/// //
/// // clap sees the above as 'myapp -f -z -F -o val'
/// // ^0 ^1 ^2 ^3 ^4 ^5
/// assert_eq!(m.index_of("flag"), Some(1));
/// assert_eq!(m.index_of("flag2"), Some(3));
/// assert_eq!(m.index_of("flag3"), Some(2));
@ -716,11 +716,11 @@ impl ArgMatches {
/// .use_delimiter(true)
/// .multiple_values(true))
/// .get_matches_from(vec!["myapp", "-o=val1,val2,val3"]);
/// // ARGV indices: ^0 ^1
/// // clap indices: ^2 ^3 ^4
/// //
/// // clap sees the above as 'myapp -o val1 val2 val3'
/// // ^0 ^1 ^2 ^3 ^4
/// // ARGV indices: ^0 ^1
/// // clap indices: ^2 ^3 ^4
/// //
/// // clap sees the above as 'myapp -o val1 val2 val3'
/// // ^0 ^1 ^2 ^3 ^4
/// assert_eq!(m.index_of("option"), Some(2));
/// assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2, 3, 4]);
/// ```
@ -755,11 +755,11 @@ impl ArgMatches {
/// .use_delimiter(true)
/// .multiple_values(true))
/// .get_matches_from(vec!["myapp", "-o=val1,val2,val3"]);
/// // ARGV indices: ^0 ^1
/// // clap indices: ^2 ^3 ^4
/// //
/// // clap sees the above as 'myapp -o val1 val2 val3'
/// // ^0 ^1 ^2 ^3 ^4
/// // ARGV indices: ^0 ^1
/// // clap indices: ^2 ^3 ^4
/// //
/// // clap sees the above as 'myapp -o val1 val2 val3'
/// // ^0 ^1 ^2 ^3 ^4
/// assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2, 3, 4]);
/// ```
///
@ -776,8 +776,8 @@ impl ArgMatches {
/// .short('f')
/// .multiple_occurrences(true))
/// .get_matches_from(vec!["myapp", "-o", "val1", "-f", "-o", "val2", "-f"]);
/// // ARGV indices: ^0 ^1 ^2 ^3 ^4 ^5 ^6
/// // clap indices: ^2 ^3 ^5 ^6
/// // ARGV indices: ^0 ^1 ^2 ^3 ^4 ^5 ^6
/// // clap indices: ^2 ^3 ^5 ^6
///
/// assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2, 5]);
/// assert_eq!(m.indices_of("flag").unwrap().collect::<Vec<_>>(), &[3, 6]);
@ -796,11 +796,11 @@ impl ArgMatches {
/// .takes_value(true)
/// .multiple_values(true))
/// .get_matches_from(vec!["myapp", "-o=val1,val2,val3"]);
/// // ARGV indices: ^0 ^1
/// // clap indices: ^2
/// //
/// // clap sees the above as 'myapp -o "val1,val2,val3"'
/// // ^0 ^1 ^2
/// // ARGV indices: ^0 ^1
/// // clap indices: ^2
/// //
/// // clap sees the above as 'myapp -o "val1,val2,val3"'
/// // ^0 ^1 ^2
/// assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2]);
/// ```
/// [`ArgMatches::index_of`]: ArgMatches::index_of()