Use Self instead of the full name of the structure.

https://rust-lang.github.io/rust-clippy/master/index.html#use_self
This commit is contained in:
Nick Lewycky
2020-10-08 20:15:47 -07:00
parent f06dced6d1
commit fdf70880db

View File

@@ -23,17 +23,17 @@ pub struct Global {
impl Global { impl Global {
/// Create a new `Global` with the initial value [`Val`]. /// Create a new `Global` with the initial value [`Val`].
pub fn new(store: &Store, val: Val) -> Global { pub fn new(store: &Store, val: Val) -> Self {
Self::from_value(store, val, Mutability::Const).unwrap() Self::from_value(store, val, Mutability::Const).unwrap()
} }
/// Create a mutable `Global` with the initial value [`Val`]. /// Create a mutable `Global` with the initial value [`Val`].
pub fn new_mut(store: &Store, val: Val) -> Global { pub fn new_mut(store: &Store, val: Val) -> Self {
Self::from_value(store, val, Mutability::Var).unwrap() Self::from_value(store, val, Mutability::Var).unwrap()
} }
/// Create a `Global` with the initial value [`Val`] and the provided [`Mutability`]. /// Create a `Global` with the initial value [`Val`] and the provided [`Mutability`].
fn from_value(store: &Store, val: Val, mutability: Mutability) -> Result<Global, RuntimeError> { fn from_value(store: &Store, val: Val, mutability: Mutability) -> Result<Self, RuntimeError> {
if !val.comes_from_same_store(store) { if !val.comes_from_same_store(store) {
return Err(RuntimeError::new("cross-`Store` globals are not supported")); return Err(RuntimeError::new("cross-`Store` globals are not supported"));
} }
@@ -47,7 +47,7 @@ impl Global {
.map_err(|e| RuntimeError::new(format!("create global for {:?}: {}", val, e)))?; .map_err(|e| RuntimeError::new(format!("create global for {:?}: {}", val, e)))?;
}; };
Ok(Global { Ok(Self {
store: store.clone(), store: store.clone(),
global: Arc::new(global), global: Arc::new(global),
}) })
@@ -87,15 +87,15 @@ impl Global {
Ok(()) Ok(())
} }
pub(crate) fn from_export(store: &Store, wasmer_export: ExportGlobal) -> Global { pub(crate) fn from_export(store: &Store, wasmer_export: ExportGlobal) -> Self {
Global { Self {
store: store.clone(), store: store.clone(),
global: wasmer_export.from.clone(), global: wasmer_export.from.clone(),
} }
} }
/// Returns whether or not these two globals refer to the same data. /// Returns whether or not these two globals refer to the same data.
pub fn same(&self, other: &Global) -> bool { pub fn same(&self, other: &Self) -> bool {
Arc::ptr_eq(&self.global, &other.global) Arc::ptr_eq(&self.global, &other.global)
} }
} }