Clippy fixes
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
f2b0d3b9f3
commit
aae41b93bb
|
@ -151,7 +151,7 @@ mod tests {
|
||||||
|
|
||||||
fn get_user(level: LevelInt) -> Pokemon {
|
fn get_user(level: LevelInt) -> Pokemon {
|
||||||
let lib = Arc::new(crate::dynamic_data::libraries::dynamic_library::test::build());
|
let lib = Arc::new(crate::dynamic_data::libraries::dynamic_library::test::build());
|
||||||
let species = lib.static_data().species().get(&"foo".into()).unwrap().clone();
|
let species = lib.static_data().species().get(&"foo".into()).unwrap();
|
||||||
let form = species.get_form(&"default".into()).unwrap();
|
let form = species.get_form(&"default".into()).unwrap();
|
||||||
|
|
||||||
Pokemon::new(
|
Pokemon::new(
|
||||||
|
|
|
@ -117,7 +117,7 @@ impl Battle {
|
||||||
number_of_hits,
|
number_of_hits,
|
||||||
choice.user().clone(),
|
choice.user().clone(),
|
||||||
used_move.clone(),
|
used_move.clone(),
|
||||||
move_data.clone(),
|
move_data,
|
||||||
move_choice.script().clone(),
|
move_choice.script().clone(),
|
||||||
);
|
);
|
||||||
let mut prevented = false;
|
let mut prevented = false;
|
||||||
|
|
|
@ -141,8 +141,7 @@ impl Pokemon {
|
||||||
.static_data()
|
.static_data()
|
||||||
.natures()
|
.natures()
|
||||||
.get_nature(nature)
|
.get_nature(nature)
|
||||||
.unwrap_or_else(|| panic!("Unknown nature name was given: {}.", &nature))
|
.unwrap_or_else(|| panic!("Unknown nature name was given: {}.", &nature));
|
||||||
.clone();
|
|
||||||
let mut pokemon = Self {
|
let mut pokemon = Self {
|
||||||
identifier: Default::default(),
|
identifier: Default::default(),
|
||||||
library,
|
library,
|
||||||
|
@ -892,7 +891,7 @@ pub mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn construct_pokemon() {
|
fn construct_pokemon() {
|
||||||
let lib = mock_library();
|
let lib = mock_library();
|
||||||
let species = lib.static_data().species().get(&"foo".into()).unwrap().clone();
|
let species = lib.static_data().species().get(&"foo".into()).unwrap();
|
||||||
let form = species.get_form(&"default".into()).unwrap();
|
let form = species.get_form(&"default".into()).unwrap();
|
||||||
|
|
||||||
let pokemon = Pokemon::new(
|
let pokemon = Pokemon::new(
|
||||||
|
|
|
@ -46,7 +46,7 @@ impl PokemonBuilder {
|
||||||
Random::default()
|
Random::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let species = self.library.static_data().species().get(&self.species).unwrap().clone();
|
let species = self.library.static_data().species().get(&self.species).unwrap();
|
||||||
let form = species.get_default_form();
|
let form = species.get_default_form();
|
||||||
let p = Pokemon::new(
|
let p = Pokemon::new(
|
||||||
self.library,
|
self.library,
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl ScriptSet {
|
||||||
|
|
||||||
/// Adds a script with a name to the set. If the script with that name already exists in this
|
/// Adds a script with a name to the set. If the script with that name already exists in this
|
||||||
/// set, this makes that script stack instead. The return value here is that script.
|
/// set, this makes that script stack instead. The return value here is that script.
|
||||||
pub fn stack_or_add<'b, F>(&self, key: &StringKey, instantiation: &'b F) -> PkmnResult<Option<ScriptContainer>>
|
pub fn stack_or_add<F>(&self, key: &StringKey, instantiation: &F) -> PkmnResult<Option<ScriptContainer>>
|
||||||
where
|
where
|
||||||
F: Fn() -> PkmnResult<Option<Arc<dyn Script>>>,
|
F: Fn() -> PkmnResult<Option<Arc<dyn Script>>>,
|
||||||
{
|
{
|
||||||
|
|
|
@ -261,7 +261,7 @@ extern "C" fn pokemon_is_ability_overriden(ptr: ExternPointer<Arc<Pokemon>>) ->
|
||||||
/// Returns the currently active ability.
|
/// Returns the currently active ability.
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
extern "C" fn pokemon_active_ability(ptr: ExternPointer<Arc<Pokemon>>) -> IdentifiablePointer<Arc<dyn Ability>> {
|
extern "C" fn pokemon_active_ability(ptr: ExternPointer<Arc<Pokemon>>) -> IdentifiablePointer<Arc<dyn Ability>> {
|
||||||
ptr.as_ref().active_ability().clone().into()
|
ptr.as_ref().active_ability().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether or not the Pokemon is allowed to gain experience.
|
/// Whether or not the Pokemon is allowed to gain experience.
|
||||||
|
|
|
@ -35,7 +35,7 @@ unsafe extern "C" fn nature_library_get_nature(
|
||||||
name: BorrowedPtr<c_char>,
|
name: BorrowedPtr<c_char>,
|
||||||
) -> IdentifiablePointer<Arc<dyn Nature>> {
|
) -> IdentifiablePointer<Arc<dyn Nature>> {
|
||||||
if let Some(nature) = ptr.as_ref().get_nature(&CStr::from_ptr(name).into()) {
|
if let Some(nature) = ptr.as_ref().get_nature(&CStr::from_ptr(name).into()) {
|
||||||
nature.clone().into()
|
nature.into()
|
||||||
} else {
|
} else {
|
||||||
IdentifiablePointer::none()
|
IdentifiablePointer::none()
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl Display for PokemonError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
PokemonError::ScriptNotFound { category, name } => {
|
PokemonError::ScriptNotFound { category, name } => {
|
||||||
write!(f, "No script found with category `{}` and name `{}`", category, name)
|
write!(f, "No script found with category `{category}` and name `{name}`")
|
||||||
}
|
}
|
||||||
PokemonError::InvalidTargetRequested => {
|
PokemonError::InvalidTargetRequested => {
|
||||||
write!(f, "Invalid target was requested")
|
write!(f, "Invalid target was requested")
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl<T: ValueIdentifiable + ?Sized> ExternRef<T> {
|
||||||
|
|
||||||
/// Returns the real value for a given ExternRef. Note that the requested type must be the same as the type of the
|
/// Returns the real value for a given ExternRef. Note that the requested type must be the same as the type of the
|
||||||
/// value when it was passed before. If these types do not match, this will panic.
|
/// value when it was passed before. If these types do not match, this will panic.
|
||||||
pub fn value_func<'a, 'b>(&'a self, env: &'b FunctionEnvMut<WebAssemblyEnv>) -> Option<&'b T>
|
pub fn value_func<'a>(&self, env: &'a FunctionEnvMut<WebAssemblyEnv>) -> Option<&'a T>
|
||||||
where
|
where
|
||||||
T: Sized + 'static,
|
T: Sized + 'static,
|
||||||
{
|
{
|
||||||
|
@ -85,7 +85,7 @@ impl<T: ValueIdentifiable + ?Sized> ExternRef<T> {
|
||||||
|
|
||||||
/// Returns the real value for a given ExternRef. Note that the requested type must be the same as the type of the
|
/// Returns the real value for a given ExternRef. Note that the requested type must be the same as the type of the
|
||||||
/// value when it was passed before. If these types do not match, this will panic.
|
/// value when it was passed before. If these types do not match, this will panic.
|
||||||
pub fn value<'a, 'b, 'c>(&'a self, env: &'b Arc<WebAssemblyEnvironmentData>) -> Option<&'c T>
|
pub fn value<'a>(&self, env: &Arc<WebAssemblyEnvironmentData>) -> Option<&'a T>
|
||||||
where
|
where
|
||||||
T: Sized + 'static,
|
T: Sized + 'static,
|
||||||
{
|
{
|
||||||
|
|
|
@ -382,7 +382,7 @@ impl WebAssemblyEnvironmentData {
|
||||||
pub fn get_extern_vec_ref_extern_ref(&self, extern_vec_ref: usize, index: usize) -> usize {
|
pub fn get_extern_vec_ref_extern_ref(&self, extern_vec_ref: usize, index: usize) -> usize {
|
||||||
let r = self.extern_vec_ref_lookup.read();
|
let r = self.extern_vec_ref_lookup.read();
|
||||||
let v = r.get(&extern_vec_ref).unwrap();
|
let v = r.get(&extern_vec_ref).unwrap();
|
||||||
v[index as usize]
|
v[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the extern ref index belonging to a specific pointer. If none exists, this will create
|
/// Gets the extern ref index belonging to a specific pointer. If none exists, this will create
|
||||||
|
@ -393,7 +393,7 @@ impl WebAssemblyEnvironmentData {
|
||||||
ptr: value as *const dyn Any,
|
ptr: value as *const dyn Any,
|
||||||
is_vec,
|
is_vec,
|
||||||
}) {
|
}) {
|
||||||
return *v as usize;
|
return *v;
|
||||||
}
|
}
|
||||||
let index = {
|
let index = {
|
||||||
let mut extern_ref_guard = self.extern_ref_pointers.write();
|
let mut extern_ref_guard = self.extern_ref_pointers.write();
|
||||||
|
@ -416,7 +416,7 @@ impl WebAssemblyEnvironmentData {
|
||||||
|
|
||||||
/// Gets a value from the extern ref lookup. This turns an earlier registered index back into
|
/// Gets a value from the extern ref lookup. This turns an earlier registered index back into
|
||||||
/// its proper value, validates its type, and returns the value.
|
/// its proper value, validates its type, and returns the value.
|
||||||
pub fn get_extern_ref_value<'a, 'b, T: ?Sized>(&'a self, index: usize) -> &'b dyn Any {
|
pub fn get_extern_ref_value<'a, T: ?Sized>(&self, index: usize) -> &'a dyn Any {
|
||||||
let read_guard = self.extern_ref_pointers.read();
|
let read_guard = self.extern_ref_pointers.read();
|
||||||
let ptr = read_guard.get(index - 1).unwrap();
|
let ptr = read_guard.get(index - 1).unwrap();
|
||||||
if self
|
if self
|
||||||
|
|
|
@ -92,10 +92,10 @@ impl From<StringKey> for EffectParameter {
|
||||||
impl Display for EffectParameter {
|
impl Display for EffectParameter {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
EffectParameter::Bool(_, v) => f.write_fmt(format_args!("EffectParameter::Bool({})", v)),
|
EffectParameter::Bool(_, v) => f.write_fmt(format_args!("EffectParameter::Bool({v})")),
|
||||||
EffectParameter::Int(_, v) => f.write_fmt(format_args!("EffectParameter::Int({})", v)),
|
EffectParameter::Int(_, v) => f.write_fmt(format_args!("EffectParameter::Int({v})")),
|
||||||
EffectParameter::Float(_, v) => f.write_fmt(format_args!("EffectParameter::Float({})", v)),
|
EffectParameter::Float(_, v) => f.write_fmt(format_args!("EffectParameter::Float({v})")),
|
||||||
EffectParameter::String(_, v) => f.write_fmt(format_args!("EffectParameter::String({})", v)),
|
EffectParameter::String(_, v) => f.write_fmt(format_args!("EffectParameter::String({v})")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue