github.com/xg0n/routine@v0.0.0-20240119033701-c364deb94aee/thread_local_map_entry.go (about)

     1  package routine
     2  
     3  type entry any
     4  
     5  func entryValue[T any](e entry) T {
     6  	if e == nil {
     7  		var defaultValue T
     8  		return defaultValue
     9  	}
    10  	return e.(T)
    11  }
    12  
    13  func entryAssert[T any](e entry) (T, bool) {
    14  	v, ok := e.(T)
    15  	return v, ok
    16  }