summary refs log tree commit diff stats
path: root/compiler/packagehandling.nim
Commit message (Expand)AuthorAgeFilesLines
* IC: next steps (#16550)Andreas Rumpf2021-01-071-1/+2
* Correct all eggs (#15906)Miran2020-11-101-2/+2
* Big compiler Cleanup (#14777)Clyybber2020-08-281-2/+0
* fix #13150 `nim doc --project` now works reliably (#13223)Timothee Cour2020-02-061-5/+8
* Fixes #12734 (#12784)Tomohiro2019-12-011-1/+4
* fixes #12420 [backport] (#12456)Andreas Rumpf2019-10-181-8/+5
* Fix #12242, replacing ":" with "@c" in packages [backport] (#12265)Endeg2019-09-251-2/+2
* changed name mangling for generated C filesAraq2019-09-131-2/+2
* Fixed c filenames mangling (#12161)Yuriy Glukhov2019-09-111-3/+3
* fix #12130 ; improve naming scheme in fakePackageNameTimothee Cour2019-09-061-5/+3
* typoAraq2019-05-081-1/+1
* fixes #11196Araq2019-05-081-2/+2
* nicer 'CC' output messagesAraq2019-05-061-0/+4
* remove the restriction that module names need to be unique per Nimbleā€¦ (#11...Andreas Rumpf2019-04-201-4/+10
* compiler refactoring; use typesafe path handing; docgen: render symbols betwe...Andreas Rumpf2018-09-071-3/+3
* even more strict isNil handling for strings/seqs in order to detect bugsAraq2018-08-221-1/+2
* guards.nim does compileAndreas Rumpf2018-05-111-15/+8
* happy new yearAraq2017-01-071-1/+1
* expr and stmt are now deprecatedAndreas Rumpf2016-07-301-1/+1
* fixes #4485; package handling works better; docgen works with --project on Ni...Andreas Rumpf2016-07-191-0/+56
m's Runtime Library # (c) Copyright 2020 Nim Contributors # # See the file "copying.txt", included in this # distribution, for details about the copyright. # ## This module adds functionality for the built-in `set` type. ## ## See also ## ======== ## * `std/packedsets <packedsets.html>`_ ## * `std/sets <sets.html>`_ import std/[typetraits, macros] #[ type SetElement* = char|byte|bool|int16|uint16|enum|uint8|int8 ## The allowed types of a built-in set. ]# template toSet*(iter: untyped): untyped = ## Returns a built-in set from the elements of the iterable `iter`. runnableExamples: assert "helloWorld".toSet == {'W', 'd', 'e', 'h', 'l', 'o', 'r'} assert toSet([10u16, 20, 30]) == {10u16, 20, 30} assert [30u8, 100, 10].toSet == {10u8, 30, 100} assert toSet(@[1321i16, 321, 90]) == {90i16, 321, 1321} assert toSet([false]) == {false} assert toSet(0u8..10) == {0u8..10} var result: set[elementType(iter)] for x in iter: incl(result, x) result macro enumElementsAsSet(enm: typed): untyped = result = newNimNode(nnkCurly).add(enm.getType[1][1..^1]) # func fullSet*(T: typedesc): set[T] {.inline.} = # xxx would give: Error: ordinal type expected func fullSet*[T](U: typedesc[T]): set[T] {.inline.} = ## Returns a set containing all elements in `U`. runnableExamples: assert bool.fullSet == {true, false} type A = range[1..3] assert A.fullSet == {1.A, 2, 3} assert int8.fullSet.len == 256 when T is Ordinal: {T.low..T.high} else: # Hole filled enum enumElementsAsSet(T) func complement*[T](s: set[T]): set[T] {.inline.} = ## Returns the set complement of `a`. runnableExamples: type Colors = enum red, green = 3, blue assert complement({red, blue}) == {green} assert complement({red, green, blue}).card == 0 assert complement({range[0..10](0), 1, 2, 3}) == {range[0..10](4), 5, 6, 7, 8, 9, 10} assert complement({'0'..'9'}) == {0.char..255.char} - {'0'..'9'} fullSet(T) - s func `[]=`*[T](t: var set[T], key: T, val: bool) {.inline.} = ## Syntax sugar for `if val: t.incl key else: t.excl key` runnableExamples: type A = enum a0, a1, a2, a3 var s = {a0, a3} s[a0] = false s[a1] = false assert s == {a3} s[a2] = true s[a3] = true assert s == {a2, a3} if val: t.incl key else: t.excl key