diff --git a/cursor/cursor.go b/cursor/cursor.go index f6ff7d1..7a765fd 100644 --- a/cursor/cursor.go +++ b/cursor/cursor.go @@ -89,37 +89,3 @@ func (rac ReaderAtCursor) At(pos uint64) Cursor[byte] { rac.pos = pos return rac } - -// StringCursor is identical to SliceCursor[byte], but uses a string as its data source. -// The advantage is that creating a StringCursor does not require copying the source -// string into a []byte. -type StringCursor struct { - source string - offset uint64 -} - -func NewString(s string) StringCursor { - return StringCursor{source: s} -} - -func (sc StringCursor) Read(dst []byte) (n uint64, next Cursor[byte], err error) { - if sc.offset == uint64(len(sc.source)) { - return 0, sc, io.EOF - } - copied := copy(dst, sc.source[sc.offset:]) - if copied < len(dst) { - err = io.EOF - } - n = uint64(copied) - sc.offset += n - return n, sc, err -} - -func (sc StringCursor) Pos() uint64 { - return sc.offset -} - -func (sc StringCursor) At(pos uint64) Cursor[byte] { - sc.offset = pos - return sc -} diff --git a/cursor/cursor_test.go b/cursor/cursor_test.go index 3b71009..1602b67 100644 --- a/cursor/cursor_test.go +++ b/cursor/cursor_test.go @@ -80,12 +80,6 @@ func TestSliceCursor(t *testing.T) { testCursor(t, cursor.NewSlice[byte]) } -func TestStringCursor(t *testing.T) { - testCursor(t, func(b []byte) cursor.StringCursor { - return cursor.NewString(string(b)) - }) -} - func TestReaderAtCursor(t *testing.T) { testCursor(t, func(b []byte) cursor.ReaderAtCursor { return cursor.NewReaderAt(bytes.NewReader(b))