Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for UnreadByte (0.1 sec)

  1. src/bytes/reader_test.go

    	buf := NewBuffer([]byte("groucho"))
    	if _, _, err := buf.ReadRune(); err != nil {
    		// should not happen
    		t.Fatal(err)
    	}
    	if err := buf.UnreadByte(); err != nil {
    		// should not happen
    		t.Fatal(err)
    	}
    	if err := buf.UnreadByte(); err == nil {
    		t.Fatal("UnreadByte: expected error, got nil")
    	}
    }
    
    // verify that copying from an empty reader always has the same results,
    Registered: Tue Nov 05 11:13:11 UTC 2024
    - Last Modified: Mon Dec 13 18:45:54 UTC 2021
    - 8K bytes
    - Viewed (0)
  2. src/bytes/reader.go

    	r.prevRune = -1
    	if r.i >= int64(len(r.s)) {
    		return 0, io.EOF
    	}
    	b := r.s[r.i]
    	r.i++
    	return b, nil
    }
    
    // UnreadByte complements [Reader.ReadByte] in implementing the [io.ByteScanner] interface.
    func (r *Reader) UnreadByte() error {
    	if r.i <= 0 {
    		return errors.New("bytes.Reader.UnreadByte: at beginning of slice")
    	}
    	r.prevRune = -1
    	r.i--
    	return nil
    }
    
    // ReadRune implements the [io.RuneReader] interface.
    Registered: Tue Nov 05 11:13:11 UTC 2024
    - Last Modified: Tue Jul 16 18:17:37 UTC 2024
    - 3.9K bytes
    - Viewed (0)
Back to top