Skip to content

Commit c8713c8

Browse files
committed
Upgrade to 2018 edition
1 parent 5eb0407 commit c8713c8

34 files changed

+1660
-1659
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ keywords = ["winrt", "uwp", "windows", "runtime", "com"]
1111
categories = ["os::windows-apis", "api-bindings", "external-ffi-bindings"]
1212
license = "MIT OR Apache-2.0"
1313
exclude = ["Generator/**"]
14+
edition = "2018"
1415

1516
[dependencies]
1617
winapi = { version = "0.3", features = ["winnt", "combaseapi", "oleauto", "roapi", "roerrorapi", "hstring", "winstring", "winerror", "restrictederrorinfo"] }

Generator/Generator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private void WriteModuleTreeMultiFile(Module mod, DirectoryInfo directory, Strea
130130
{
131131
if (mod.IsEmpty) return;
132132

133-
const string IMPORTS = "use ::prelude::*;";
133+
const string IMPORTS = "use crate::prelude::*;";
134134

135135
string name = mod.Name.ToLower();
136136
string newPath = path == null ? mod.Name : (path + "." + mod.Name);

Generator/Types/TypeDef.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public string GetPath(Module requestingModule)
214214
}
215215
else
216216
{
217-
name = $"::rt::gen::{ Module.Path }::{ Name }";
217+
name = $"crate::{ Module.Path }::{ Name }";
218218
}
219219
var relative = $"{ Module.GetRelativePath(requestingModule) }::{ Name }";
220220
if (relative.Length < name.Length)

examples/hexdump.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const CHUNK_SIZE: usize = 4096;
1515

1616
fn main() {
1717
// Use the current executable as source file (because we know that will exist).
18-
let exe_path = ::std::env::current_exe().expect("current_exe failed");
18+
let exe_path = std::env::current_exe().expect("current_exe failed");
1919
let exe_path_str = exe_path.to_str().expect("invalid unicode path");
2020

2121
let file = StorageFile::get_file_from_path_async(&*FastHString::new(&exe_path_str)).unwrap().blocking_get().expect("get_file_from_path_async failed").unwrap();

examples/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ fn main() {
144144
assert!(asi.close().is_ok());
145145

146146
// Walk directories up to root
147-
let exe_path = ::std::env::current_exe().expect("current_exe failed");
147+
let exe_path = std::env::current_exe().expect("current_exe failed");
148148
let exe_path_str = exe_path.to_str().expect("invalid unicode path");
149149
let file = StorageFile::get_file_from_path_async(&*FastHString::new(&exe_path_str)).unwrap().blocking_get().expect("get_file_from_path_async failed").unwrap();
150150
println!("Executable file: {}", file.query_interface::<IStorageItem>().unwrap().get_path().unwrap());

src/bstr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use ::std::ptr;
2-
use ::std::fmt;
1+
use std::ptr;
2+
use std::fmt;
33

44
use w::shared::wtypes::BSTR;
55
use w::shared::basetsd::UINT32;
@@ -63,7 +63,7 @@ impl BStr {
6363
} else {
6464
unsafe {
6565
let len = self.len();
66-
let slice: &[u16] = ::std::slice::from_raw_parts(self.0, len as usize);
66+
let slice: &[u16] = std::slice::from_raw_parts(self.0, len as usize);
6767
String::from_utf16_lossy(slice)
6868
}
6969
}

src/cominterfaces.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use Guid;
1+
use crate::Guid;
22
use w::um::unknwnbase::IUnknownVtbl;
33

44
/// Marker trait for all COM-compatible interfaces.
@@ -21,15 +21,15 @@ pub trait ComIid {
2121
DEFINE_IID!(IID_IUnknown, 0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
2222

2323
/// Re-export from WinAPI crate
24-
pub type IUnknown = ::w::um::unknwnbase::IUnknown;
24+
pub type IUnknown = w::um::unknwnbase::IUnknown;
2525
impl ComIid for IUnknown { #[inline] fn iid() -> &'static Guid { &IID_IUnknown } }
2626
impl ComInterface for IUnknown { type Vtbl = IUnknownVtbl; }
2727

2828
DEFINE_IID!(IID_IRestrictedErrorInfo, 0x82BA7092, 0x4C88, 0x427D, 0xA7, 0xBC, 0x16, 0xDD, 0x93, 0xFE, 0xB6, 0x7E);
2929

3030
/// Re-export from WinAPI crate
31-
pub type IRestrictedErrorInfo = ::w::um::restrictederrorinfo::IRestrictedErrorInfo;
32-
pub type IRestrictedErrorInfoVtbl = ::w::um::restrictederrorinfo::IRestrictedErrorInfoVtbl;
31+
pub type IRestrictedErrorInfo = w::um::restrictederrorinfo::IRestrictedErrorInfo;
32+
pub type IRestrictedErrorInfoVtbl = w::um::restrictederrorinfo::IRestrictedErrorInfoVtbl;
3333
impl ComIid for IRestrictedErrorInfo { #[inline] fn iid() -> &'static Guid { &IID_IRestrictedErrorInfo } }
3434
impl ComInterface for IRestrictedErrorInfo { type Vtbl = IRestrictedErrorInfoVtbl; }
3535

@@ -42,17 +42,17 @@ DEFINE_IID!(IID_IAgileObject, 0x94EA2B94, 0xE9CC, 0x49E0, 0xC0, 0xFF, 0xEE, 0x64
4242
pub struct IAgileObject {
4343
lpVtbl: *const IUnknownVtbl // IAgileObject has no methods besides what IUnknown has
4444
}
45-
impl ::std::ops::Deref for IAgileObject {
45+
impl std::ops::Deref for IAgileObject {
4646
type Target = IUnknown;
4747
#[inline]
4848
fn deref(&self) -> &IUnknown {
49-
unsafe { ::std::mem::transmute(self) }
49+
unsafe { std::mem::transmute(self) }
5050
}
5151
}
52-
impl ::std::ops::DerefMut for IAgileObject {
52+
impl std::ops::DerefMut for IAgileObject {
5353
#[inline]
5454
fn deref_mut(&mut self) -> &mut IUnknown {
55-
unsafe { ::std::mem::transmute(self) }
55+
unsafe { std::mem::transmute(self) }
5656
}
5757
}
5858
impl ComIid for IAgileObject { #[inline] fn iid() -> &'static Guid { &IID_IAgileObject } }

src/comptr.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::ops::{Deref, DerefMut};
22
use std::fmt;
33
use std::ptr;
4-
use ::{ComIid, ComInterface, RtInterface, RtClassInterface, IInspectable, Guid};
4+
use crate::{ComIid, ComInterface, RtInterface, RtClassInterface, IInspectable, Guid};
55

66
use w::shared::ntdef::VOID;
77
use w::shared::minwindef::LPVOID;
@@ -38,7 +38,7 @@ pub fn query_interface<T, Target>(interface: &T) -> Option<ComPtr<Target>> where
3838

3939
// This trait is not exported in the library interface
4040
pub trait HiddenGetRuntimeClassName {
41-
fn get_runtime_class_name(&self) -> ::HString;
41+
fn get_runtime_class_name(&self) -> crate::HString;
4242
}
4343

4444
impl<T> ComPtr<T> {
@@ -80,7 +80,7 @@ impl<T> ComPtr<T> {
8080
/// This is a runtime no-op, but you need to be sure that the interface is compatible.
8181
#[inline]
8282
pub unsafe fn into_unchecked<Interface>(self) -> ComPtr<Interface> where Interface: ComInterface {
83-
::std::mem::transmute(self)
83+
std::mem::transmute(self)
8484
}
8585

8686
/// Gets the fully qualified name of the current Windows Runtime object.
@@ -100,7 +100,7 @@ impl<T> ComPtr<T> {
100100
/// assert_eq!("Windows.Foundation.Uri", uri.get_runtime_class_name().to_string());
101101
/// ```
102102
#[inline]
103-
pub fn get_runtime_class_name(&self) -> ::HString where T: RtClassInterface {
103+
pub fn get_runtime_class_name(&self) -> crate::HString where T: RtClassInterface {
104104
HiddenGetRuntimeClassName::get_runtime_class_name(self.as_inspectable())
105105
}
106106

@@ -150,12 +150,12 @@ impl<T> PartialEq<ComPtr<T>> for ComPtr<T> {
150150
/// Owned array type that is used as return type when WinRT methods return arrays.
151151
/// It wraps a block of memory that has been allocated by WinRT and will be deallocated
152152
/// using `CoTaskMemFree` on drop.
153-
pub struct ComArray<T> where T: ::RtType {
153+
pub struct ComArray<T> where T: crate::RtType {
154154
size: u32,
155155
first: ptr::NonNull<T::Abi>
156156
}
157157

158-
impl<T> ComArray<T> where T: ::RtType {
158+
impl<T> ComArray<T> where T: crate::RtType {
159159
#[inline]
160160
pub unsafe fn from_raw(size: u32, first: *mut T::Abi) -> ComArray<T> {
161161
assert!(!first.is_null());
@@ -172,25 +172,25 @@ impl<T> ComArray<T> where T: ::RtType {
172172
}
173173
}
174174

175-
impl<T> Deref for ComArray<T> where T: ::RtType {
175+
impl<T> Deref for ComArray<T> where T: crate::RtType {
176176
type Target = [T::OutNonNull];
177177
#[inline]
178178
fn deref(&self) -> &[T::OutNonNull] {
179-
unsafe { ::std::slice::from_raw_parts(self.first.as_ptr() as *mut T::OutNonNull, self.size as usize) }
179+
unsafe { std::slice::from_raw_parts(self.first.as_ptr() as *mut T::OutNonNull, self.size as usize) }
180180
}
181181
}
182-
impl<T> DerefMut for ComArray<T> where T: ::RtType {
182+
impl<T> DerefMut for ComArray<T> where T: crate::RtType {
183183
#[inline]
184184
fn deref_mut(&mut self) -> &mut [T::OutNonNull] {
185-
unsafe { ::std::slice::from_raw_parts_mut(self.first.as_ptr() as *mut T::OutNonNull, self.size as usize) }
185+
unsafe { std::slice::from_raw_parts_mut(self.first.as_ptr() as *mut T::OutNonNull, self.size as usize) }
186186
}
187187
}
188188

189-
impl<T> Drop for ComArray<T> where T: ::RtType {
189+
impl<T> Drop for ComArray<T> where T: crate::RtType {
190190
#[inline]
191191
fn drop(&mut self) {
192192
unsafe {
193-
::std::ptr::drop_in_place(&mut self[..]);
193+
std::ptr::drop_in_place(&mut self[..]);
194194
CoTaskMemFree(self.first.as_ptr() as LPVOID)
195195
};
196196
}
@@ -201,8 +201,8 @@ mod extra {
201201
// i.e. when a compiler version is used that still has dropflags
202202
#[inline]
203203
fn assert_no_dropflags() {
204-
let p: *mut ::IInspectable = ::std::ptr::null_mut();
205-
let _: ::ComPtr<::IInspectable> = unsafe { ::std::mem::transmute(p) };
204+
let p: *mut crate::IInspectable = std::ptr::null_mut();
205+
let _: crate::ComPtr<crate::IInspectable> = unsafe { std::mem::transmute(p) };
206206
}
207207
}
208208

@@ -212,10 +212,10 @@ mod tests {
212212

213213
#[test]
214214
fn check_sizes() {
215-
use ::std::mem::size_of;
215+
use std::mem::size_of;
216216

217217
// make sure that ComPtr is pointer-sized
218-
assert_eq!(size_of::<::ComPtr<::IInspectable>>(), size_of::<*mut ::IInspectable>());
219-
assert_eq!(size_of::<Option<::ComPtr<::IInspectable>>>(), size_of::<*mut ::IInspectable>());
218+
assert_eq!(size_of::<crate::ComPtr<crate::IInspectable>>(), size_of::<*mut crate::IInspectable>());
219+
assert_eq!(size_of::<Option<crate::ComPtr<crate::IInspectable>>>(), size_of::<*mut crate::IInspectable>());
220220
}
221221
}

src/guid.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ mod tests {
5050

5151
#[test]
5252
fn check_size() {
53-
use ::std::mem::size_of;
53+
use std::mem::size_of;
5454

55-
assert_eq!(size_of::<::Guid>(), size_of::<::w::shared::guiddef::GUID>());
55+
assert_eq!(size_of::<crate::Guid>(), size_of::<w::shared::guiddef::GUID>());
5656
}
5757
}

src/hstring.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn internal_to_string(hstr: HSTRING) -> String {
2121
unsafe {
2222
let mut len = 0;
2323
let buf = WindowsGetStringRawBuffer(hstr, &mut len);
24-
let slice: &[u16] = ::std::slice::from_raw_parts(buf, len as usize);
24+
let slice: &[u16] = std::slice::from_raw_parts(buf, len as usize);
2525
String::from_utf16_lossy(slice)
2626
}
2727
}
@@ -453,7 +453,7 @@ impl HString {
453453
pub fn make_reference<'a>(&'a self) -> HStringReference<'a> {
454454
let mut len = 0;
455455
let buf = unsafe { WindowsGetStringRawBuffer(self.0, &mut len) };
456-
unsafe { HStringReference::from_utf16_unchecked(::std::slice::from_raw_parts(buf, len as usize + 1)) }
456+
unsafe { HStringReference::from_utf16_unchecked(std::slice::from_raw_parts(buf, len as usize + 1)) }
457457
}
458458
}
459459

@@ -467,7 +467,7 @@ impl Drop for HString {
467467

468468
unsafe impl Send for HString {}
469469

470-
impl ::std::clone::Clone for HString {
470+
impl std::clone::Clone for HString {
471471
#[inline]
472472
fn clone(&self) -> Self {
473473
let mut clone = HString::empty();
@@ -577,9 +577,9 @@ mod tests {
577577

578578
#[test]
579579
fn check_sizes() {
580-
use ::std::mem::size_of;
581-
assert_eq!(size_of::<::HString>(), size_of::<::w::winrt::hstring::HSTRING>());
582-
assert_eq!(size_of::<&::HStringArg>(), size_of::<::w::winrt::hstring::HSTRING>());
580+
use std::mem::size_of;
581+
assert_eq!(size_of::<crate::HString>(), size_of::<w::winrt::hstring::HSTRING>());
582+
assert_eq!(size_of::<&crate::HStringArg>(), size_of::<w::winrt::hstring::HSTRING>());
583583
}
584584

585585
#[test]

0 commit comments

Comments
 (0)