forked from moigagoo/norm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moigagoo#159 Moved procs into utils module
Renamed "isContainer" to "isRefObject" Added documentation to utility procs
- Loading branch information
1 parent
4ff0fc9
commit b39f970
Showing
3 changed files
with
37 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import std/options | ||
|
||
func isRefObject*[T](val: typedesc[T]): bool {.compileTime.} = | ||
## Checks if a given type is of type ref object | ||
T is ref object | ||
|
||
func isRefObject*[T](val: T): bool {.compileTime.} = | ||
## Checks if a given variable is of type ref object | ||
T is ref object | ||
|
||
func isRefObject*[T](val: typedesc[Option[T]]): bool {.compileTime.} = | ||
## Checks if the inner type of an given optional type is a ref object | ||
T is ref object | ||
|
||
func isRefObject*[T](val: Option[T]): bool {.compileTime.} = | ||
## Checks if the inner type of the optional variable is a ref object | ||
T is ref object | ||
|
||
func toOptional*[T: ref object](val: T): Option[T] = | ||
## Converts non optional type to optional type | ||
some val | ||
|
||
func toOptional*[T: ref object](val: Option[T]): Option[T] = | ||
## Convert optional type to optional type, doing effectively nothing | ||
val |