Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for ContainsRune (0.18 sec)

  1. src/bytes/bytes.go

    func (as *asciiSet) contains(c byte) bool {
    	return (as[c/32] & (1 << (c % 32))) != 0
    }
    
    // containsRune is a simplified version of strings.ContainsRune
    // to avoid importing the strings package.
    // We avoid bytes.ContainsRune to avoid allocating a temporary copy of s.
    func containsRune(s string, r rune) bool {
    	for _, c := range s {
    		if c == r {
    			return true
    		}
    	}
    	return false
    }
    
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Mon Feb 19 19:51:15 GMT 2024
    - 33.8K bytes
    - Viewed (0)
  2. src/bytes/example_test.go

    	// true
    	// false
    	// false
    }
    
    func ExampleContainsRune() {
    	fmt.Println(bytes.ContainsRune([]byte("I like seafood."), 'f'))
    	fmt.Println(bytes.ContainsRune([]byte("I like seafood."), 'ö'))
    	fmt.Println(bytes.ContainsRune([]byte("去是伟大的!"), '大'))
    	fmt.Println(bytes.ContainsRune([]byte("去是伟大的!"), '!'))
    	fmt.Println(bytes.ContainsRune([]byte(""), '@'))
    	// Output:
    	// true
    	// false
    	// true
    	// true
    	// false
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Mon Mar 04 15:54:40 GMT 2024
    - 15K bytes
    - Viewed (1)
  3. src/bytes/bytes_test.go

    	{[]byte("a☺b☻c☹d"), '☻', true},
    	{[]byte("aRegExp*"), '*', true},
    }
    
    func TestContainsRune(t *testing.T) {
    	for _, ct := range ContainsRuneTests {
    		if ContainsRune(ct.b, ct.r) != ct.expected {
    			t.Errorf("ContainsRune(%q, %q) = %v, want %v",
    				ct.b, ct.r, !ct.expected, ct.expected)
    		}
    	}
    }
    
    func TestContainsFunc(t *testing.T) {
    	for _, ct := range ContainsRuneTests {
    Go
    - Registered: Tue Apr 30 11:13:12 GMT 2024
    - Last Modified: Wed Jan 24 16:07:25 GMT 2024
    - 56.2K bytes
    - Viewed (0)
Back to top