Use Self instead of repeating the type name.

This commit is contained in:
Dan Gohman
2017-11-08 10:40:47 -08:00
parent b7f979a8be
commit 3ab4349c1b
41 changed files with 105 additions and 105 deletions

View File

@@ -12,8 +12,8 @@ pub struct Keys<K: EntityRef> {
impl<K: EntityRef> Keys<K> {
/// Create a `Keys` iterator that visits `count` entities starting from 0.
pub fn new(count: usize) -> Keys<K> {
Keys {
pub fn new(count: usize) -> Self {
Self {
pos: 0,
rev_pos: count,
unused: PhantomData,

View File

@@ -68,7 +68,7 @@ pub struct EntityList<T: EntityRef> {
/// Create an empty list.
impl<T: EntityRef> Default for EntityList<T> {
fn default() -> Self {
EntityList {
Self {
index: 0,
unused: PhantomData,
}
@@ -82,7 +82,7 @@ impl<T: EntityRef> Hash for EntityList<T> {
}
impl<T: EntityRef> PartialEq for EntityList<T> {
fn eq(&self, _: &EntityList<T>) -> bool {
fn eq(&self, _: &Self) -> bool {
panic!("eq called on EntityList");
}
}
@@ -121,8 +121,8 @@ fn is_sclass_min_length(len: usize) -> bool {
impl<T: EntityRef> ListPool<T> {
/// Create a new list pool.
pub fn new() -> ListPool<T> {
ListPool {
pub fn new() -> Self {
Self {
data: Vec::new(),
free: Vec::new(),
}
@@ -311,7 +311,7 @@ impl<T: EntityRef> EntityList<T> {
/// Take all elements from this list and return them as a new list. Leave this list empty.
///
/// This is the equivalent of `Option::take()`.
pub fn take(&mut self) -> EntityList<T> {
pub fn take(&mut self) -> Self {
mem::replace(self, Default::default())
}

View File

@@ -34,7 +34,7 @@ where
where
V: Default,
{
EntityMap {
Self {
elems: Vec::new(),
default: Default::default(),
unused: PhantomData,
@@ -45,7 +45,7 @@ where
///
/// This constructor does not require V to implement Default.
pub fn with_default(default: V) -> Self {
EntityMap {
Self {
elems: Vec::new(),
default: default,
unused: PhantomData,

View File

@@ -27,7 +27,7 @@ where
{
/// Create a new empty map.
pub fn new() -> Self {
PrimaryMap {
Self {
elems: Vec::new(),
unused: PhantomData,
}

View File

@@ -24,7 +24,7 @@ where
{
/// Create a new empty set.
pub fn new() -> Self {
EntitySet {
Self {
elems: Vec::new(),
len: 0,
unused: PhantomData,

View File

@@ -66,7 +66,7 @@ where
{
/// Create a new empty mapping.
pub fn new() -> Self {
SparseMap {
Self {
sparse: EntityMap::new(),
dense: Vec::new(),
}
@@ -215,7 +215,7 @@ impl<T> SparseMapValue<T> for T
where
T: EntityRef,
{
fn key(&self) -> T {
fn key(&self) -> Self {
*self
}
}