code: func (s *State) CompareAges(other *State) (StateAgeComparison, error) {
  	// nil states are "older" than actual states
  	switch {
  	case s != nil && other == nil:
  		return StateAgeReceiverNewer, nil
  	case s == nil && other != nil:
  		return StateAgeReceiverOlder, nil
  	case s == nil && other == nil:
  		return StateAgeEqual, nil
  	}
  
  	if !s.SameLineage(other) {
  		return StateAgeEqual, fmt.Errorf(
  			"can't compare two states of differing lineage",
  		)
  	}
  
  	s.Lock()
  	defer s.Unlock()
  
  	switch {
  	case s.Serial < other.Serial:
  		return StateAgeReceiverOlder, nil
  	case s.Serial > other.Serial:
  		return StateAgeReceiverNewer, nil
  	default:
  		return StateAgeEqual, nil
  	}
  }
docs: // CompareAges compares one state with another for which is "older".
  //
  // This is a simple check using the state's serial, and is thus only as
  // reliable as the serial itself. In the normal case, only one state
  // exists for a given combination of lineage/serial, but Terraform
  // does not guarantee this and so the result of this method should be
  // used with care.
  //
  // Returns an integer that is negative if the receiver is older than
  // the argument, positive if the converse, and zero if they are equal.
  // An error is returned if the two states are not of the same lineage,
  // in which case the integer returned has no meaning.