@hazae41/box
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,1 +0,1 @@ | ||
export { Box, BoxMovedError } from './mods/box/box.js'; | ||
export { Box, BoxMovedError, Copiable } from './mods/box/box.js'; |
@@ -8,2 +8,9 @@ import { Result } from '@hazae41/result'; | ||
} | ||
interface Copiable<T> { | ||
copy(): T; | ||
} | ||
declare namespace Copiable { | ||
type Infer<T> = Copiable<Copied<T>>; | ||
type Copied<T> = T extends Copiable<infer U> ? U : never; | ||
} | ||
declare class Box<T extends Disposable> { | ||
@@ -48,7 +55,13 @@ #private; | ||
* Move the inner value to a new box and set this one as moved | ||
* @returns Ok<T> or Err<BoxMovedError> if already moved | ||
* @returns Ok<Box<T>> or Err<BoxMovedError> if already moved | ||
*/ | ||
tryMove(): Result<Box<T>, BoxMovedError>; | ||
/** | ||
* Create a new Box that's already moved, and keep this one as is | ||
* @returns Box<T> | ||
*/ | ||
greed(): Box<T>; | ||
static copy<T extends Disposable & Copiable.Infer<T>>(inner: Box<T>): Copiable.Copied<T>; | ||
} | ||
export { Box, BoxMovedError }; | ||
export { Box, BoxMovedError, Copiable }; |
{ | ||
"type": "module", | ||
"name": "@hazae41/box", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Rust-like Box for TypeScript", | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/hazae41/box", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
19372
279