sttk / linebreak

A library for breaking a given text into lines within a specified width.
MIT License
0 stars 0 forks source link

fix: changed LineIter API to .HasNext + .Next #26

Closed sttk closed 1 month ago

sttk commented 1 month ago

This PR changes LineIter's APIs:

  1. Changes the 'more' flag returned by LineIter#Next to 'exists' flag

        line, exists := iter.Next()   // 'exists' indicates that the current 'line' is valid
        if exists {
            fmt.Println(line)
        }
  2. Adds LineIter#HasNext that indicates the following LineIter#Next call returns a valid line string.

        for iter.HasNext() {
            line, _ := iter.Next()
            fmt.Println(line)
        }

Closes #25