Skip to content

Commit fc87bc5

Browse files
holimanfjl
authored andcommitted
common: improve documentation of Hash.SetBytes (#15062)
Fixes #15004
1 parent c1740e4 commit fc87bc5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

common/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (h Hash) MarshalText() ([]byte, error) {
8888
return hexutil.Bytes(h[:]).MarshalText()
8989
}
9090

91-
// Sets the hash to the value of b. If b is larger than len(h) it will panic
91+
// Sets the hash to the value of b. If b is larger than len(h), 'b' will be cropped (from the left).
9292
func (h *Hash) SetBytes(b []byte) {
9393
if len(b) > len(h) {
9494
b = b[len(b)-HashLength:]
@@ -97,7 +97,7 @@ func (h *Hash) SetBytes(b []byte) {
9797
copy(h[HashLength-len(b):], b)
9898
}
9999

100-
// Set string `s` to h. If s is larger than len(h) it will panic
100+
// Set string `s` to h. If s is larger than len(h) s will be cropped (from left) to fit.
101101
func (h *Hash) SetString(s string) { h.SetBytes([]byte(s)) }
102102

103103
// Sets h to other

0 commit comments

Comments
 (0)