From 6ff22058ba37c0064820c260255d9435842916e3 Mon Sep 17 00:00:00 2001 From: klensy Date: Sun, 10 Dec 2023 13:23:06 +0300 Subject: [PATCH 1/3] clean com.rs --- src/windows/com.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/windows/com.rs b/src/windows/com.rs index e81bb1d3..be9f13ff 100644 --- a/src/windows/com.rs +++ b/src/windows/com.rs @@ -6,7 +6,6 @@ // except according to those terms. #![allow(unused)] - use crate::windows::{ winapi::{IUnknown, Interface}, windows_sys::{ @@ -17,7 +16,6 @@ use crate::windows::{ use std::{ convert::TryInto, ffi::{OsStr, OsString}, - mem::ManuallyDrop, ops::Deref, os::windows::ffi::{OsStrExt, OsStringExt}, ptr::{null, null_mut}, @@ -48,19 +46,6 @@ where assert!(!ptr.is_null()); ComPtr(ptr) } - /// Casts up the inheritance chain - pub fn up(self) -> ComPtr - where - T: Deref, - U: Interface, - { - ComPtr(self.into_raw() as *mut U) - } - /// Extracts the raw pointer. - /// You are now responsible for releasing it yourself. - pub fn into_raw(self) -> *mut T { - ManuallyDrop::new(self).0 - } /// For internal use only. fn as_unknown(&self) -> &IUnknown { unsafe { &*(self.0 as *mut IUnknown) } From eb903d71452a981c030552366f35c28eb87f1215 Mon Sep 17 00:00:00 2001 From: klensy Date: Sun, 10 Dec 2023 13:35:14 +0300 Subject: [PATCH 2/3] remove allow(deprecated) trim_left_matches deprecated from 1.33, current msrv is 1.53 --- src/lib.rs | 1 - src/windows/find_tools.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d7122aec..cb2e51ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -217,7 +217,6 @@ #![doc(html_root_url = "https://docs.rs/cc/1.0")] #![cfg_attr(test, deny(warnings))] -#![allow(deprecated)] #![deny(missing_docs)] use std::borrow::Cow; diff --git a/src/windows/find_tools.rs b/src/windows/find_tools.rs index b0061948..c4a92bde 100644 --- a/src/windows/find_tools.rs +++ b/src/windows/find_tools.rs @@ -928,7 +928,7 @@ mod impl_ { for subkey in key.iter().filter_map(|k| k.ok()) { let val = subkey .to_str() - .and_then(|s| s.trim_left_matches("v").replace('.', "").parse().ok()); + .and_then(|s| s.trim_start_matches("v").replace('.', "").parse().ok()); let val = match val { Some(s) => s, None => continue, From 0ea7af7c6fd03398f901c555fcdfc272043f44ba Mon Sep 17 00:00:00 2001 From: klensy Date: Wed, 8 May 2024 12:02:52 +0300 Subject: [PATCH 3/3] more com.rs clean --- src/windows/com.rs | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/src/windows/com.rs b/src/windows/com.rs index be9f13ff..0391b5af 100644 --- a/src/windows/com.rs +++ b/src/windows/com.rs @@ -5,7 +5,6 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. -#![allow(unused)] use crate::windows::{ winapi::{IUnknown, Interface}, windows_sys::{ @@ -15,9 +14,9 @@ use crate::windows::{ }; use std::{ convert::TryInto, - ffi::{OsStr, OsString}, + ffi::OsString, ops::Deref, - os::windows::ffi::{OsStrExt, OsStringExt}, + os::windows::ffi::OsStringExt, ptr::{null, null_mut}, slice::from_raw_parts, }; @@ -109,34 +108,3 @@ impl Drop for BStr { unsafe { SysFreeString(self.0) }; } } - -pub trait ToWide { - fn to_wide(&self) -> Vec; - fn to_wide_null(&self) -> Vec; -} -impl ToWide for T -where - T: AsRef, -{ - fn to_wide(&self) -> Vec { - self.as_ref().encode_wide().collect() - } - fn to_wide_null(&self) -> Vec { - self.as_ref().encode_wide().chain(Some(0)).collect() - } -} -pub trait FromWide -where - Self: Sized, -{ - fn from_wide(wide: &[u16]) -> Self; - fn from_wide_null(wide: &[u16]) -> Self { - let len = wide.iter().take_while(|&&c| c != 0).count(); - Self::from_wide(&wide[..len]) - } -} -impl FromWide for OsString { - fn from_wide(wide: &[u16]) -> OsString { - OsStringExt::from_wide(wide) - } -}