Fix new clippy lints

This commit is contained in:
Filip Tibell 2024-08-10 13:34:13 +02:00
parent 833d0e244b
commit 56f08a88aa
No known key found for this signature in database
7 changed files with 34 additions and 32 deletions

View file

@ -26,7 +26,7 @@ pub fn add_methods<'lua, M: LuaUserDataMethods<'lua, Instance>>(m: &mut M) {
### See Also ### See Also
* [`Terrain`](https://create.roblox.com/docs/reference/engine/classes/Workspace#Terrain) * [`Terrain`](https://create.roblox.com/docs/reference/engine/classes/Workspace#Terrain)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
fn data_model_get_workspace(_: &Lua, this: &Instance) -> LuaResult<Instance> { fn data_model_get_workspace(_: &Lua, this: &Instance) -> LuaResult<Instance> {
get_or_create_property_ref_instance(this, "Workspace", "Workspace") get_or_create_property_ref_instance(this, "Workspace", "Workspace")
@ -37,7 +37,7 @@ fn data_model_get_workspace(_: &Lua, this: &Instance) -> LuaResult<Instance> {
### See Also ### See Also
* [`GetService`](https://create.roblox.com/docs/reference/engine/classes/ServiceProvider#GetService) * [`GetService`](https://create.roblox.com/docs/reference/engine/classes/ServiceProvider#GetService)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
fn data_model_get_service(_: &Lua, this: &Instance, service_name: String) -> LuaResult<Instance> { fn data_model_get_service(_: &Lua, this: &Instance, service_name: String) -> LuaResult<Instance> {
if matches!(class_is_a_service(&service_name), None | Some(false)) { if matches!(class_is_a_service(&service_name), None | Some(false)) {
@ -58,7 +58,7 @@ fn data_model_get_service(_: &Lua, this: &Instance, service_name: String) -> Lua
### See Also ### See Also
* [`FindService`](https://create.roblox.com/docs/reference/engine/classes/ServiceProvider#FindService) * [`FindService`](https://create.roblox.com/docs/reference/engine/classes/ServiceProvider#FindService)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
fn data_model_find_service( fn data_model_find_service(
_: &Lua, _: &Lua,

View file

@ -170,7 +170,7 @@ impl Instance {
### See Also ### See Also
* [`Clone`](https://create.roblox.com/docs/reference/engine/classes/Instance#Clone) * [`Clone`](https://create.roblox.com/docs/reference/engine/classes/Instance#Clone)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
#[must_use] #[must_use]
pub fn clone_instance(&self) -> Self { pub fn clone_instance(&self) -> Self {
@ -194,7 +194,7 @@ impl Instance {
### See Also ### See Also
* [`Destroy`](https://create.roblox.com/docs/reference/engine/classes/Instance#Destroy) * [`Destroy`](https://create.roblox.com/docs/reference/engine/classes/Instance#Destroy)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn destroy(&mut self) -> bool { pub fn destroy(&mut self) -> bool {
if self.is_destroyed() { if self.is_destroyed() {
@ -221,7 +221,7 @@ impl Instance {
### See Also ### See Also
* [`Instance::Destroy`] for more info about what happens when an instance gets destroyed * [`Instance::Destroy`] for more info about what happens when an instance gets destroyed
* [`ClearAllChildren`](https://create.roblox.com/docs/reference/engine/classes/Instance#ClearAllChildren) * [`ClearAllChildren`](https://create.roblox.com/docs/reference/engine/classes/Instance#ClearAllChildren)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn clear_all_children(&mut self) { pub fn clear_all_children(&mut self) {
let mut dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let mut dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -241,7 +241,7 @@ impl Instance {
### See Also ### See Also
* [`IsA`](https://create.roblox.com/docs/reference/engine/classes/Instance#IsA) * [`IsA`](https://create.roblox.com/docs/reference/engine/classes/Instance#IsA)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn is_a(&self, class_name: impl AsRef<str>) -> bool { pub fn is_a(&self, class_name: impl AsRef<str>) -> bool {
class_is_a(&self.class_name, class_name).unwrap_or(false) class_is_a(&self.class_name, class_name).unwrap_or(false)
@ -254,7 +254,7 @@ impl Instance {
### See Also ### See Also
* [`ClassName`](https://create.roblox.com/docs/reference/engine/classes/Instance#ClassName) * [`ClassName`](https://create.roblox.com/docs/reference/engine/classes/Instance#ClassName)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
#[must_use] #[must_use]
pub fn get_class_name(&self) -> &str { pub fn get_class_name(&self) -> &str {
@ -266,7 +266,7 @@ impl Instance {
### See Also ### See Also
* [`Name`](https://create.roblox.com/docs/reference/engine/classes/Instance#Name) * [`Name`](https://create.roblox.com/docs/reference/engine/classes/Instance#Name)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn get_name(&self) -> String { pub fn get_name(&self) -> String {
let dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -282,7 +282,7 @@ impl Instance {
### See Also ### See Also
* [`Name`](https://create.roblox.com/docs/reference/engine/classes/Instance#Name) * [`Name`](https://create.roblox.com/docs/reference/engine/classes/Instance#Name)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn set_name(&self, name: impl Into<String>) { pub fn set_name(&self, name: impl Into<String>) {
let mut dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let mut dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -297,7 +297,7 @@ impl Instance {
### See Also ### See Also
* [`Parent`](https://create.roblox.com/docs/reference/engine/classes/Instance#Parent) * [`Parent`](https://create.roblox.com/docs/reference/engine/classes/Instance#Parent)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn get_parent(&self) -> Option<Instance> { pub fn get_parent(&self) -> Option<Instance> {
let dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -324,7 +324,7 @@ impl Instance {
### See Also ### See Also
* [`Parent`](https://create.roblox.com/docs/reference/engine/classes/Instance#Parent) * [`Parent`](https://create.roblox.com/docs/reference/engine/classes/Instance#Parent)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn set_parent(&self, parent: Option<Instance>) { pub fn set_parent(&self, parent: Option<Instance>) {
let mut dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let mut dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -369,7 +369,7 @@ impl Instance {
### See Also ### See Also
* [`GetAttribute`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetAttribute) * [`GetAttribute`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetAttribute)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn get_attribute(&self, name: impl AsRef<str>) -> Option<DomValue> { pub fn get_attribute(&self, name: impl AsRef<str>) -> Option<DomValue> {
let dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -390,7 +390,7 @@ impl Instance {
### See Also ### See Also
* [`GetAttributes`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetAttributes) * [`GetAttributes`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetAttributes)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn get_attributes(&self) -> BTreeMap<String, DomValue> { pub fn get_attributes(&self) -> BTreeMap<String, DomValue> {
let dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -411,7 +411,7 @@ impl Instance {
### See Also ### See Also
* [`SetAttribute`](https://create.roblox.com/docs/reference/engine/classes/Instance#SetAttribute) * [`SetAttribute`](https://create.roblox.com/docs/reference/engine/classes/Instance#SetAttribute)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn set_attribute(&self, name: impl AsRef<str>, value: DomValue) { pub fn set_attribute(&self, name: impl AsRef<str>, value: DomValue) {
let mut dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let mut dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -466,7 +466,7 @@ impl Instance {
### See Also ### See Also
* [`AddTag`](https://create.roblox.com/docs/reference/engine/classes/CollectionService#AddTag) * [`AddTag`](https://create.roblox.com/docs/reference/engine/classes/CollectionService#AddTag)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn add_tag(&self, name: impl AsRef<str>) { pub fn add_tag(&self, name: impl AsRef<str>) {
let mut dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let mut dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -488,7 +488,7 @@ impl Instance {
### See Also ### See Also
* [`GetTags`](https://create.roblox.com/docs/reference/engine/classes/CollectionService#GetTags) * [`GetTags`](https://create.roblox.com/docs/reference/engine/classes/CollectionService#GetTags)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn get_tags(&self) -> Vec<String> { pub fn get_tags(&self) -> Vec<String> {
let dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -507,7 +507,7 @@ impl Instance {
### See Also ### See Also
* [`HasTag`](https://create.roblox.com/docs/reference/engine/classes/CollectionService#HasTag) * [`HasTag`](https://create.roblox.com/docs/reference/engine/classes/CollectionService#HasTag)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn has_tag(&self, name: impl AsRef<str>) -> bool { pub fn has_tag(&self, name: impl AsRef<str>) -> bool {
let dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -527,7 +527,7 @@ impl Instance {
### See Also ### See Also
* [`RemoveTag`](https://create.roblox.com/docs/reference/engine/classes/CollectionService#RemoveTag) * [`RemoveTag`](https://create.roblox.com/docs/reference/engine/classes/CollectionService#RemoveTag)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn remove_tag(&self, name: impl AsRef<str>) { pub fn remove_tag(&self, name: impl AsRef<str>) {
let mut dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let mut dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -553,7 +553,7 @@ impl Instance {
### See Also ### See Also
* [`GetChildren`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetChildren) * [`GetChildren`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetChildren)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn get_children(&self) -> Vec<Instance> { pub fn get_children(&self) -> Vec<Instance> {
let dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -576,7 +576,7 @@ impl Instance {
### See Also ### See Also
* [`GetDescendants`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetDescendants) * [`GetDescendants`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetDescendants)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn get_descendants(&self) -> Vec<Instance> { pub fn get_descendants(&self) -> Vec<Instance> {
let dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -610,7 +610,7 @@ impl Instance {
### See Also ### See Also
* [`GetFullName`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetFullName) * [`GetFullName`](https://create.roblox.com/docs/reference/engine/classes/Instance#GetFullName)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn get_full_name(&self) -> String { pub fn get_full_name(&self) -> String {
let dom = INTERNAL_DOM.lock().expect("Failed to lock document"); let dom = INTERNAL_DOM.lock().expect("Failed to lock document");
@ -700,7 +700,7 @@ impl Instance {
### See Also ### See Also
* [`FindFirstDescendant`](https://create.roblox.com/docs/reference/engine/classes/Instance#FindFirstDescendant) * [`FindFirstDescendant`](https://create.roblox.com/docs/reference/engine/classes/Instance#FindFirstDescendant)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
pub fn find_descendant<F>(&self, predicate: F) -> Option<Instance> pub fn find_descendant<F>(&self, predicate: F) -> Option<Instance>
where where

View file

@ -40,7 +40,7 @@ fn get_or_create_material_colors(instance: &Instance) -> MaterialColors {
### See Also ### See Also
* [`GetMaterialColor`](https://create.roblox.com/docs/reference/engine/classes/Terrain#GetMaterialColor) * [`GetMaterialColor`](https://create.roblox.com/docs/reference/engine/classes/Terrain#GetMaterialColor)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
fn terrain_get_material_color(_: &Lua, this: &Instance, material: EnumItem) -> LuaResult<Color3> { fn terrain_get_material_color(_: &Lua, this: &Instance, material: EnumItem) -> LuaResult<Color3> {
let material_colors = get_or_create_material_colors(this); let material_colors = get_or_create_material_colors(this);
@ -65,7 +65,7 @@ fn terrain_get_material_color(_: &Lua, this: &Instance, material: EnumItem) -> L
### See Also ### See Also
* [`SetMaterialColor`](https://create.roblox.com/docs/reference/engine/classes/Terrain#SetMaterialColor) * [`SetMaterialColor`](https://create.roblox.com/docs/reference/engine/classes/Terrain#SetMaterialColor)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
fn terrain_set_material_color( fn terrain_set_material_color(
_: &Lua, _: &Lua,

View file

@ -16,7 +16,7 @@ pub fn add_fields<'lua, F: LuaUserDataFields<'lua, Instance>>(f: &mut F) {
### See Also ### See Also
* [`Terrain`](https://create.roblox.com/docs/reference/engine/classes/Workspace#Terrain) * [`Terrain`](https://create.roblox.com/docs/reference/engine/classes/Workspace#Terrain)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
fn workspace_get_terrain(_: &Lua, this: &Instance) -> LuaResult<Instance> { fn workspace_get_terrain(_: &Lua, this: &Instance) -> LuaResult<Instance> {
get_or_create_property_ref_instance(this, "Terrain", "Terrain") get_or_create_property_ref_instance(this, "Terrain", "Terrain")
@ -27,7 +27,7 @@ fn workspace_get_terrain(_: &Lua, this: &Instance) -> LuaResult<Instance> {
### See Also ### See Also
* [`CurrentCamera`](https://create.roblox.com/docs/reference/engine/classes/Workspace#CurrentCamera) * [`CurrentCamera`](https://create.roblox.com/docs/reference/engine/classes/Workspace#CurrentCamera)
on the Roblox Developer Hub on the Roblox Developer Hub
*/ */
fn workspace_get_camera(_: &Lua, this: &Instance) -> LuaResult<Instance> { fn workspace_get_camera(_: &Lua, this: &Instance) -> LuaResult<Instance> {
get_or_create_property_ref_instance(this, "CurrentCamera", "Camera") get_or_create_property_ref_instance(this, "CurrentCamera", "Camera")

View file

@ -18,6 +18,7 @@ impl LuaRequest {
let path = self.head.uri.path().to_string(); let path = self.head.uri.path().to_string();
let body = lua.create_string(&self.body)?; let body = lua.create_string(&self.body)?;
#[allow(clippy::mutable_key_type)]
let query: HashMap<LuaString, LuaString> = self let query: HashMap<LuaString, LuaString> = self
.head .head
.uri .uri
@ -32,6 +33,7 @@ impl LuaRequest {
}) })
.collect::<LuaResult<_>>()?; .collect::<LuaResult<_>>()?;
#[allow(clippy::mutable_key_type)]
let headers: HashMap<LuaString, LuaString> = self let headers: HashMap<LuaString, LuaString> = self
.head .head
.headers .headers

View file

@ -42,8 +42,8 @@ pub fn module(lua: &Lua) -> LuaResult<LuaTable> {
cwd_str.push(MAIN_SEPARATOR); cwd_str.push(MAIN_SEPARATOR);
} }
// Create constants for OS & processor architecture // Create constants for OS & processor architecture
let os = lua.create_string(&OS.to_lowercase())?; let os = lua.create_string(OS.to_lowercase())?;
let arch = lua.create_string(&ARCH.to_lowercase())?; let arch = lua.create_string(ARCH.to_lowercase())?;
// Create readonly args array // Create readonly args array
let args_vec = lua let args_vec = lua
.app_data_ref::<Vec<String>>() .app_data_ref::<Vec<String>>()

View file

@ -194,14 +194,14 @@ pub fn prompt(options: PromptOptions) -> LuaResult<PromptResult> {
prompt = prompt.default(b); prompt = prompt.default(b);
}; };
let result = prompt let result = prompt
.with_prompt(&options.text.expect("Missing text in prompt options")) .with_prompt(options.text.expect("Missing text in prompt options"))
.interact() .interact()
.into_lua_err()?; .into_lua_err()?;
Ok(PromptResult::Boolean(result)) Ok(PromptResult::Boolean(result))
} }
PromptKind::Select => { PromptKind::Select => {
let chosen = Select::with_theme(&theme) let chosen = Select::with_theme(&theme)
.with_prompt(&options.text.unwrap_or_default()) .with_prompt(options.text.unwrap_or_default())
.items(&options.options.expect("Missing options in prompt options")) .items(&options.options.expect("Missing options in prompt options"))
.interact_opt() .interact_opt()
.into_lua_err()?; .into_lua_err()?;
@ -212,7 +212,7 @@ pub fn prompt(options: PromptOptions) -> LuaResult<PromptResult> {
} }
PromptKind::MultiSelect => { PromptKind::MultiSelect => {
let chosen = MultiSelect::with_theme(&theme) let chosen = MultiSelect::with_theme(&theme)
.with_prompt(&options.text.unwrap_or_default()) .with_prompt(options.text.unwrap_or_default())
.items(&options.options.expect("Missing options in prompt options")) .items(&options.options.expect("Missing options in prompt options"))
.interact_opt() .interact_opt()
.into_lua_err()?; .into_lua_err()?;