From 085b461bdc25a9901c9c2a7a511f280a2c98666d Mon Sep 17 00:00:00 2001 From: Saul Gutierrez Date: Wed, 19 Apr 2023 17:41:33 -0700 Subject: [PATCH] Get rid of experimental features --- examples/regfs/main.rs | 1 - src/guid.rs | 28 ++++++++++++++++------------ src/lib.rs | 2 -- src/option.rs | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/examples/regfs/main.rs b/examples/regfs/main.rs index 11ef431..ee39579 100644 --- a/examples/regfs/main.rs +++ b/examples/regfs/main.rs @@ -1,4 +1,3 @@ -#![feature(try_trait, slice_concat_trait)] use anyhow::Result; use prjfs::provider::{Provider, ProviderT}; use prjfs::{NotificationType, OptionBuilder}; diff --git a/src/guid.rs b/src/guid.rs index e3993a8..985d3bc 100644 --- a/src/guid.rs +++ b/src/guid.rs @@ -1,3 +1,4 @@ +use anyhow::{Result, bail}; use winapi::shared::guiddef::GUID; use winapi::um::combaseapi::CoCreateGuid; @@ -7,21 +8,24 @@ pub fn create_guid() -> GUID { guid } -pub fn guid_from_bytes(bytes: Vec) -> std::result::Result { +pub fn guid_from_bytes(bytes: Vec) -> Result { + if bytes.len() < 16 { + bail!("Not enough bytes for converting into a GUID"); + } let mut guid = bytes.into_iter(); Ok(GUID { - Data1: u32::from_be_bytes([guid.next()?, guid.next()?, guid.next()?, guid.next()?]), - Data2: u16::from_be_bytes([guid.next()?, guid.next()?]), - Data3: u16::from_be_bytes([guid.next()?, guid.next()?]), + Data1: u32::from_be_bytes([guid.next().unwrap(), guid.next().unwrap(), guid.next().unwrap(), guid.next().unwrap()]), + Data2: u16::from_be_bytes([guid.next().unwrap(), guid.next().unwrap()]), + Data3: u16::from_be_bytes([guid.next().unwrap(), guid.next().unwrap()]), Data4: [ - guid.next()?, - guid.next()?, - guid.next()?, - guid.next()?, - guid.next()?, - guid.next()?, - guid.next()?, - guid.next()?, + guid.next().unwrap(), + guid.next().unwrap(), + guid.next().unwrap(), + guid.next().unwrap(), + guid.next().unwrap(), + guid.next().unwrap(), + guid.next().unwrap(), + guid.next().unwrap(), ], }) } diff --git a/src/lib.rs b/src/lib.rs index 32cf08b..e127012 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,3 @@ -#![feature(try_trait)] - pub mod conv; pub mod guid; pub mod option; diff --git a/src/option.rs b/src/option.rs index 659759a..f93410c 100644 --- a/src/option.rs +++ b/src/option.rs @@ -22,7 +22,7 @@ bitflags::bitflags! { } impl NotificationType { - fn into_raw(self) -> crate::sys::PRJ_NOTIFY_TYPES { + fn into_raw(&self) -> crate::sys::PRJ_NOTIFY_TYPES { let mut raw = crate::sys::PRJ_NOTIFY_TYPES::default(); if self.contains(NotificationType::NONE) {