Add explicit conversion from coral::path to coral::slice
This commit is contained in:
		
							parent
							
								
									8ced8440fc
								
							
						
					
					
						commit
						3856a03ec1
					
				| @ -88,7 +88,7 @@ export namespace app { | ||||
| 
 | ||||
| 			if (path_remaining.length < file_path.byte_size()) return nullptr; | ||||
| 
 | ||||
| 			coral::copy(path_remaining, coral::slice{file_path.begin(), file_path.end()}.as_bytes()); | ||||
| 			coral::copy(path_remaining, file_path.as_slice().as_bytes()); | ||||
| 
 | ||||
| 			return ::SDL_RWFromFile(reinterpret_cast<char const *>(this->path_buffer), "r"); | ||||
| 		} | ||||
|  | ||||
| @ -29,6 +29,13 @@ export namespace coral { | ||||
| 			this->buffer[max] = max - text_size; | ||||
| 		} | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * Returns a weak reference to the [path] as a [slice]. | ||||
| 		 */ | ||||
| 		constexpr slice<char const> as_slice() const { | ||||
| 			return {this->buffer, this->byte_size()}; | ||||
| 		} | ||||
| 
 | ||||
| 		/**
 | ||||
| 		 * Returns the base pointer of the path name. | ||||
| 		 * | ||||
| @ -50,8 +57,7 @@ export namespace coral { | ||||
| 		 * they are identical. | ||||
| 		 */ | ||||
| 		constexpr size compare(path const & that) const { | ||||
| 			return coral::compare(slice{this->begin(), this->end()}.as_bytes(), | ||||
| 				slice{that.begin(), that.end()}.as_bytes()); | ||||
| 			return coral::compare(this->as_slice().as_bytes(), that.as_slice().as_bytes()); | ||||
| 		} | ||||
| 
 | ||||
| 		/**
 | ||||
| @ -66,8 +72,7 @@ export namespace coral { | ||||
| 		 * otherwise `false`. | ||||
| 		 */ | ||||
| 		constexpr bool equals(path const & that) const { | ||||
| 			return coral::equals(slice{this->begin(), this->end()}.as_bytes(), | ||||
| 				slice{that.begin(), that.end()}.as_bytes()); | ||||
| 			return coral::equals(this->as_slice().as_bytes(), that.as_slice().as_bytes()); | ||||
| 		} | ||||
| 
 | ||||
| 		/**
 | ||||
| @ -76,7 +81,7 @@ export namespace coral { | ||||
| 		 * *Note:* the returned hash code is not guaranteed to be unique. | ||||
| 		 */ | ||||
| 		constexpr u64 hash() const { | ||||
| 			return coral::hash(slice{this->begin(), this->end()}.as_bytes()); | ||||
| 			return coral::hash(this->as_slice().as_bytes()); | ||||
| 		} | ||||
| 
 | ||||
| 		/**
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user