Skip to content

name anonymous fn parameters in libcore traits #39705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
@@ -434,7 +434,7 @@ impl<'a> Display for Arguments<'a> {
pub trait Debug {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, &mut Formatter) -> Result;
fn fmt(&self, f: &mut Formatter) -> Result;
}

/// Format trait for an empty format, `{}`.
@@ -477,7 +477,7 @@ pub trait Debug {
pub trait Display {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, &mut Formatter) -> Result;
fn fmt(&self, f: &mut Formatter) -> Result;
}

/// Format trait for the `o` character.
@@ -524,7 +524,7 @@ pub trait Display {
pub trait Octal {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, &mut Formatter) -> Result;
fn fmt(&self, f: &mut Formatter) -> Result;
}

/// Format trait for the `b` character.
@@ -571,7 +571,7 @@ pub trait Octal {
pub trait Binary {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, &mut Formatter) -> Result;
fn fmt(&self, f: &mut Formatter) -> Result;
}

/// Format trait for the `x` character.
@@ -619,7 +619,7 @@ pub trait Binary {
pub trait LowerHex {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, &mut Formatter) -> Result;
fn fmt(&self, f: &mut Formatter) -> Result;
}

/// Format trait for the `X` character.
@@ -667,7 +667,7 @@ pub trait LowerHex {
pub trait UpperHex {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, &mut Formatter) -> Result;
fn fmt(&self, f: &mut Formatter) -> Result;
}

/// Format trait for the `p` character.
@@ -712,7 +712,7 @@ pub trait UpperHex {
pub trait Pointer {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, &mut Formatter) -> Result;
fn fmt(&self, f: &mut Formatter) -> Result;
}

/// Format trait for the `e` character.
@@ -755,7 +755,7 @@ pub trait Pointer {
pub trait LowerExp {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, &mut Formatter) -> Result;
fn fmt(&self, f: &mut Formatter) -> Result;
}

/// Format trait for the `E` character.
@@ -798,7 +798,7 @@ pub trait LowerExp {
pub trait UpperExp {
/// Formats the value using the given formatter.
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, &mut Formatter) -> Result;
fn fmt(&self, f: &mut Formatter) -> Result;
}

/// The `write` function takes an output stream, a precompiled format string,
20 changes: 10 additions & 10 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
@@ -1324,7 +1324,7 @@ shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
pub trait AddAssign<Rhs=Self> {
/// The method for the `+=` operator
#[stable(feature = "op_assign_traits", since = "1.8.0")]
fn add_assign(&mut self, Rhs);
fn add_assign(&mut self, rhs: Rhs);
}

macro_rules! add_assign_impl {
@@ -1380,7 +1380,7 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
pub trait SubAssign<Rhs=Self> {
/// The method for the `-=` operator
#[stable(feature = "op_assign_traits", since = "1.8.0")]
fn sub_assign(&mut self, Rhs);
fn sub_assign(&mut self, rhs: Rhs);
}

macro_rules! sub_assign_impl {
@@ -1425,7 +1425,7 @@ sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
pub trait MulAssign<Rhs=Self> {
/// The method for the `*=` operator
#[stable(feature = "op_assign_traits", since = "1.8.0")]
fn mul_assign(&mut self, Rhs);
fn mul_assign(&mut self, rhs: Rhs);
}

macro_rules! mul_assign_impl {
@@ -1470,7 +1470,7 @@ mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
pub trait DivAssign<Rhs=Self> {
/// The method for the `/=` operator
#[stable(feature = "op_assign_traits", since = "1.8.0")]
fn div_assign(&mut self, Rhs);
fn div_assign(&mut self, rhs: Rhs);
}

macro_rules! div_assign_impl {
@@ -1514,7 +1514,7 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
pub trait RemAssign<Rhs=Self> {
/// The method for the `%=` operator
#[stable(feature = "op_assign_traits", since = "1.8.0")]
fn rem_assign(&mut self, Rhs);
fn rem_assign(&mut self, rhs: Rhs);
}

macro_rules! rem_assign_impl {
@@ -1600,7 +1600,7 @@ rem_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
pub trait BitAndAssign<Rhs=Self> {
/// The method for the `&=` operator
#[stable(feature = "op_assign_traits", since = "1.8.0")]
fn bitand_assign(&mut self, Rhs);
fn bitand_assign(&mut self, rhs: Rhs);
}

macro_rules! bitand_assign_impl {
@@ -1644,7 +1644,7 @@ bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
pub trait BitOrAssign<Rhs=Self> {
/// The method for the `|=` operator
#[stable(feature = "op_assign_traits", since = "1.8.0")]
fn bitor_assign(&mut self, Rhs);
fn bitor_assign(&mut self, rhs: Rhs);
}

macro_rules! bitor_assign_impl {
@@ -1688,7 +1688,7 @@ bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
pub trait BitXorAssign<Rhs=Self> {
/// The method for the `^=` operator
#[stable(feature = "op_assign_traits", since = "1.8.0")]
fn bitxor_assign(&mut self, Rhs);
fn bitxor_assign(&mut self, rhs: Rhs);
}

macro_rules! bitxor_assign_impl {
@@ -1732,7 +1732,7 @@ bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
pub trait ShlAssign<Rhs> {
/// The method for the `<<=` operator
#[stable(feature = "op_assign_traits", since = "1.8.0")]
fn shl_assign(&mut self, Rhs);
fn shl_assign(&mut self, rhs: Rhs);
}

macro_rules! shl_assign_impl {
@@ -1797,7 +1797,7 @@ shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
pub trait ShrAssign<Rhs=Self> {
/// The method for the `>>=` operator
#[stable(feature = "op_assign_traits", since = "1.8.0")]
fn shr_assign(&mut self, Rhs);
fn shr_assign(&mut self, rhs: Rhs);
}

macro_rules! shr_assign_impl {
6 changes: 3 additions & 3 deletions src/libcore/str/pattern.rs
Original file line number Diff line number Diff line change
@@ -240,7 +240,7 @@ pub trait DoubleEndedSearcher<'a>: ReverseSearcher<'a> {}

#[doc(hidden)]
trait CharEq {
fn matches(&mut self, char) -> bool;
fn matches(&mut self, c: char) -> bool;
fn only_ascii(&self) -> bool;
}

@@ -1178,8 +1178,8 @@ impl TwoWaySearcher {
trait TwoWayStrategy {
type Output;
fn use_early_reject() -> bool;
fn rejecting(usize, usize) -> Self::Output;
fn matching(usize, usize) -> Self::Output;
fn rejecting(a: usize, b: usize) -> Self::Output;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there are more descriptive names we could use here? I don't know enough about this piece of code, but @Kimundi might.

Copy link
Contributor Author

@tspiteri tspiteri Feb 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried not to be creative and used names already used by the implementations of the trait. I didn't give too much thought to this particular example as it is actually a private trait and does not appear in the docs like the others.

Edit: Looking further into this, the names a and b are what is actually used in the docs themselves. The variants listed in std::str::pattern::SearchStep talk about haystack[a..b].

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough -- thanks!

fn matching(a: usize, b: usize) -> Self::Output;
}

/// Skip to match intervals as quickly as possible