`str.len` is the actual length of the string. it's equal to its capacity when 
allocated with `newString(cap)` but after it has been used, and more 
specifically after `str.setLen()` has been called, it does no longer contains 
the capacity.

It's just that I'd prefer to rewrite:
    
    
    const MAX_LEN = 1024
    var s = newString(MAX_LEN)
    s.setLen snprintf(s.cstring, MAX_LEN, "Foo bar %s", "Hello")
    s.setLen snprintf(s.cstring, MAX_LEN, "Foo bar %s", "HelloWorld")
    
    
    Run

into something like:
    
    
    var s = newString(1024)
    s.setLen snprintf(s.cstring, s.cap, "Foo bar %s", "Hello")
    s.setLen snprintf(s.cstring, s.cap, "Foo bar %s", "HelloWorld")
    
    
    Run

Reply via email to