Skip to content

Commit

Permalink
Add some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bwesterb committed Jul 10, 2024
1 parent 1fa0c56 commit 4775ebb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
go-and
======

Fast bitwise and for `[]byte` slices.

```go
import "github.com/bwesterb/go-and"

func main() {
var a, b, dst []byte

// ...

// Sets dst to the bitwise and of a and b
and.And(dst, a, b)
}
```
4 changes: 4 additions & 0 deletions lib.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// and implements bitwise and for two byte-slices.
package and

import (
"encoding/binary"
)

// Writes bitwise and of a and b to dst.
//
// Panics if len(a) ≠ len(b), or len(dst) ≠ len(a).
func And(dst, a, b []byte) {
if len(a) != len(b) || len(b) != len(dst) {
panic("lengths of a, b and dst must be equal")
Expand Down

0 comments on commit 4775ebb

Please sign in to comment.