Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for Conv3 (0.03 sec)

  1. test/typeparam/issue49027.dir/a.go

    }
    
    func Conv2(v interface{}) (string, bool) {
    	return conv2[string](v)
    }
    
    func conv2[T any](v interface{}) (T, bool) {
    	x, ok := v.(T)
    	return x, ok
    }
    
    func Conv3(v interface{}) string {
    	return conv3[string](v)
    }
    
    func conv3[T any](v interface{}) T {
    	switch v := v.(type) {
    	case T:
    		return v
    	default:
    		var z T
    		return z
    	}
    }
    
    type Mystring string
    
    func (Mystring) Foo() {
    }
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Oct 19 22:47:48 UTC 2021
    - 871 bytes
    - Viewed (0)
  2. test/typeparam/issue49027.dir/main.go

    	if x != s {
    		panic(fmt.Sprintf("got %s wanted %s", x, s))
    	}
    	y, ok := a.Conv2(s)
    	if !ok {
    		panic("conversion failed")
    	}
    	if y != s {
    		panic(fmt.Sprintf("got %s wanted %s", y, s))
    	}
    	z := a.Conv3(s)
    	if z != s {
    		panic(fmt.Sprintf("got %s wanted %s", z, s))
    	}
    	w := a.Conv4(a.Mystring(s))
    	if w != a.Mystring(s) {
    		panic(fmt.Sprintf("got %s wanted %s", w, s))
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Mar 24 02:14:15 UTC 2022
    - 617 bytes
    - Viewed (0)
Back to top