Skip to content

v0.9.4

Compare
Choose a tag to compare
@huacnlee huacnlee released this 23 Feb 07:34
· 5 commits to main since this release

Language

  • Add to support arbitrary parameters.

    fn foo(a: int, b: int, items: ..string) {
    }
  • Add top support iterate for channel types.

    use std.io;
    
    let ch = channel::<int>();
    spawn {
      defer {
        ch.close();
      }
      for i in 0..10 {
        ch.send(i);
      }
    }
    
    for n in ch {
      io.println(n);
    }
  • Add to support impl for.

    interface Foo {
      fn foo(self);
    }
    
    struct User {}
    
    impl for User {
      fn foo(self) {
        io.println("foo");
      }
    }
  • Add support lazy initialization.

    let s: string;
    
    s = "hello";
  • Add char type.

    let c: char = 'a';
  • Add to support while let.

    while (let v = ch.recv()) {
      io.println(v);
    }
  • Now can iterate over a string.

    let s = "hello";
    for c in s {
      io.println(c);
    }
  • Improve string performance.

  • Improve string interpolation for support ${x:?} to print debug format.

  • Improve implicit conversion to support.

    // Option type
    let a: int? = 10;
    assert_eq a!, 10;
    
    let a: int??? = 10;
    let b: int? = a;
    assert_eq b!, 10;
    
    let a: int? = 10;
    let b: int??? = a;
    assert_eq b!!!, 10;
    
    // Union type
    let a: int | string = "abc";
    assert_eq a.(string), "abc";
    
    // Interface
    let a: ToString = 10;
    assert_eq a.to_string(), "10";
  • Fix the break in do, catch block can't break the outside loop bug.

Stdlib

  • Add time.sleep method.

    use std.time;
    
    // sleep 1 second
    time.sleep(1);
  • Improve std.io.print to support arbitrary argument.

    use std.io;
    
    io.println("hello", "world");
  • Update http Headers apppend, set method, not allows nil value.

  • Update http set_basic_auth the username not allows nil.

Pkg

The pkg is used to manage packages that many split out of Navi in the future.

  • Add sql module to support SQlite, MySQL, PostgreSQL, etc.

    use sql.Connection;
    
    
    struct User {
      id: int,
      name: string,
    }
    
    const conn = try! Connection.connect("sqlite::memory:");
    try! conn.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)");
    
    try! conn.execute("INSERT INTO users (name) VALUES (?)", "Jason Lee");
    
    let users = try! conn.query("SELECT * FROM users").scan::<User>();
  • Add markdown module to support markdown render to HTML.

    use markdown;
    
    let html = markdown.to_html("# Hello, World!");

Tools

  • Fix Navi LSP to better autocomplete and documentations support.
  • Add cache support in Navi LSP for better performance.
  • Add format support in Navi LSP.
  • fmt: insert a new line after std uses.
  • fmt: sort outer-layer use { ... } statements
  • New tree-sitter-navi, tree-sitter-navi-stream project for tree-sitter support.
  • Add Zed extension support, current only syntax highlight support.