code: def adapt(cls, source, template):
      
      if not isinstance(template, packarray):
        raise TypeError('template must be a packarray')
      return cls(source, template.start, template.end)
docs: adapt source to a packarray according to the layout of template