code: func (rself *privateReaderAdapter) drain() {
  	if rself.closeReceived {
  		return // we have already drained
  	}
  
  	if len(rself.bufferToBeRead) != 0 {
  		if rself.workReceipt == nil {
  			panic("Logic error: if there's data to be read, we must still have the receipt")
  		}
  		rself.Writer.doneWorkChan <- rself.workReceipt
  		rself.workReceipt = nil
  	} else {
  		if rself.workReceipt != nil {
  			panic("Logic error: work receipt should be nil if there's no buffer to drain")
  		}
  	}
  
  	for toDrain := range rself.Writer.workChan {
  		if toDrain == nil {
  			break
  		} else {
  			rself.Writer.doneWorkChan <- toDrain
  		}
  	}
  }
docs: // drain
  //
  // This is the final function called when the wrapped io.Reader shuts down and
  // stops accepting more input.
  //
  // this is because readers like zlib don't validate the CRC32
  // (the last 4 bytes) in the normal codepath and leave the final buffer unconsumed