]> git.proxmox.com Git - rustc.git/blobdiff - vendor/tendril/src/util.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / vendor / tendril / src / util.rs
index af489e723af14f1c87755ff320ad914b86dc4e4e..28c55c1283c9017ef48697bce66890f9b2618194 100644 (file)
@@ -1,11 +1,11 @@
 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::{slice, ptr};
 use std::mem;
+use std::{ptr, slice};
 
 #[inline(always)]
 pub unsafe fn unsafe_slice<'a>(buf: &'a [u8], start: usize, new_len: usize) -> &'a [u8] {
@@ -15,7 +15,11 @@ pub unsafe fn unsafe_slice<'a>(buf: &'a [u8], start: usize, new_len: usize) -> &
 }
 
 #[inline(always)]
-pub unsafe fn unsafe_slice_mut<'a>(buf: &'a mut [u8], start: usize, new_len: usize) -> &'a mut [u8] {
+pub unsafe fn unsafe_slice_mut<'a>(
+    buf: &'a mut [u8],
+    start: usize,
+    new_len: usize,
+) -> &'a mut [u8] {
     debug_assert!(start <= buf.len());
     debug_assert!(new_len <= (buf.len() - start));
     slice::from_raw_parts_mut(buf.as_mut_ptr().offset(start as isize), new_len)
@@ -28,30 +32,14 @@ pub unsafe fn copy_and_advance(dest: &mut *mut u8, src: &[u8]) {
 }
 
 #[inline(always)]
-pub unsafe fn copy_lifetime_mut<'a, S: ?Sized, T: ?Sized + 'a>
-                           (_ptr: &'a mut S, ptr: &mut T) -> &'a mut T {
+pub unsafe fn copy_lifetime_mut<'a, S: ?Sized, T: ?Sized + 'a>(
+    _ptr: &'a mut S,
+    ptr: &mut T,
+) -> &'a mut T {
     mem::transmute(ptr)
 }
 
-
 #[inline(always)]
-pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>
-                           (_ptr: &'a S, ptr: &T) -> &'a T {
+pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, ptr: &T) -> &'a T {
     mem::transmute(ptr)
 }
-
-#[derive(Copy, Clone)]
-pub struct NonZeroUsize(&'static u8);
-
-impl NonZeroUsize {
-    #[inline]
-    pub unsafe fn new(value: usize) -> Self {
-        debug_assert!(value != 0);
-        NonZeroUsize(&*(value as *const u8))
-    }
-
-    #[inline]
-    pub fn get(self) -> usize {
-        self.0 as *const u8 as usize
-    }
-}