| 
									
										
										
										
											2019-05-24 16:21:42 -07:00
										 |  |  | use std::alloc::Layout;
 | 
					
						
							|  |  |  | use std::fmt;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /// Based loosely on the unstable std::alloc::Alloc trait
 | 
					
						
							|  |  |  | pub trait Alloc {
 | 
					
						
							| 
									
										
										
										
											2019-08-23 11:03:53 -07:00
										 |  |  |     fn alloc(&mut self, layout: Layout) -> Result<u64, AllocErr>;
 | 
					
						
							|  |  |  |     fn dealloc(&mut self, addr: u64, layout: Layout);
 | 
					
						
							| 
									
										
										
										
											2019-05-24 16:21:42 -07:00
										 |  |  | }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #[derive(Clone, PartialEq, Eq, Debug)]
 | 
					
						
							|  |  |  | pub struct AllocErr;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | impl fmt::Display for AllocErr {
 | 
					
						
							|  |  |  |     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 | 
					
						
							|  |  |  |         f.write_str("Error: Memory allocation failed")
 | 
					
						
							|  |  |  |     }
 | 
					
						
							|  |  |  | }
 |