Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Derive Copy and Clone for LayerTypes
I want to be able to inject `LayerType` into a struct instead of needing to hard code it. Currently this can be done but isn't ergonomic because `LayerTypes` is not clone, but it is serializable and deserializable and all values inside are copy. That allows us to hack around the issue currently: ``` struct InjectLayerTypes { visibility: LayerTypes, // ... } Imply Layer for InjectLayerTypes { // ... fn types(&self) -> LayerTypes { LayerTypes { launch: self.visibility.launch, build: self.visibility.build, cache: self.visibility.cache, } } // Or fn types(&self) -> LayerTypes { // Hack around LayerType not implementing `Clone` let toml_string = toml::to_string(&self.visibility).expect("LayerTypes can be serialized to toml"); let layer_types: LayerTypes = toml::from_str(&toml_string).expect("Serialized data can be deserialized"); layer_types } ``` This could be used to allow building of more generic interfaces. For example, in #598 I am trying to introduce a generic struct for use in setting environment variables. One gap in this implementation is that it assumes build, launch, cache should be true. It (or another struct) could instead make no assumptions and accept LayerTypes as an injectable value.
- Loading branch information