Skip to content

Conversation

luislavena
Copy link
Owner

After Crystal 0.15, compiler will require declare the types used by instance variables on classes.

This require changes to the usage of Radix::Tree by introducing the type of payload elements it will handle:

# Will only support symbols as payload
tree = Radix::Tree(Symbol).new
tree.add "/", :root

# Error: cannot add node with anything other than Symbol
tree.add "/meaning-of-life", 42

The changes ensure future compatibility with Crystal and also enforces a more declarative usage of Radix::Tree.

If necessary, you can combine multiple types to ensure a tree can contain all the wide range of payloads you need:

tree = Radix::Tree.new(Foo | Bar | Symbol).new
tree.add "/", :root
tree.add "/foo", foo_instance

This change includes:

  • Tree, Node and Result has been updated to require types.
  • Node is capable of have optional payload (from defined type).
  • Documentation has been updated to reflect this change.

Closes #7

After Crystal 0.15, compiler will require declare the types used
by instance variables on classes.

This require changes to the usage of `Radix::Tree` by introducing
the type of payload elements it will handle:

    # Will only support symbols as payload
    tree = Radix::Tree(Symbol).new
    tree.add "/", :root

    # Error: cannot add node with anything other than Symbol
    tree.add "/meaning-of-life", 42

The changes ensure future compatibility with Crystal and also
enforces a more declarative usage of `Radix::Tree`.

If necessary, you can combine multiple types to ensure a tree
can contain all the wide range of payloads you need:

    tree = Radix::Tree.new(Foo | Bar | Symbol).new
    tree.add "/", :root
    tree.add "/foo", foo_instance

This change includes:

- Tree, Node and Result has been updated to require types.
- Node is capable of have optional payload (from defined type).
- Documentation has been updated to reflect this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant