You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Python CNB as part of switching to the new struct layer API, I've started using the pattern of having the layer function accept an env: &mut Env argument, to allow threading the libcnb::Env around the buildpack as env vars are added to it and to allow it to be used when running commands.
However, since mutable references are being used, libcnb::Env's existing IntoIterator implementation doesn't work, instead requiring either casting to an immutable reference (ie: .envs(&*env)) or else calling libcnb::Env::iter directly (ie: .envs(env.iter())).
We could avoid the need for this by implementing impl<'a> IntoIterator for &'a mut Env.
And for completeness probably the owned impl IntoIterator for Env too.
In the Python CNB as part of switching to the new struct layer API, I've started using the pattern of having the layer function accept an
env: &mut Env
argument, to allow threading thelibcnb::Env
around the buildpack as env vars are added to it and to allow it to be used when running commands.However, since mutable references are being used,
libcnb::Env
's existingIntoIterator
implementation doesn't work, instead requiring either casting to an immutable reference (ie:.envs(&*env)
) or else callinglibcnb::Env::iter
directly (ie:.envs(env.iter())
).For example:
https://github.com/heroku/buildpacks-python/blob/92c77a653ecead1d331559bc24f0f27fb72bb9d4/src/layers/python.rs#L149
https://github.com/heroku/buildpacks-python/blob/92c77a653ecead1d331559bc24f0f27fb72bb9d4/src/layers/pip_dependencies.rs#L73
We could avoid the need for this by implementing
impl<'a> IntoIterator for &'a mut Env
.And for completeness probably the owned
impl IntoIterator for Env
too.See also Rust's 3x
IntoIterator
implementations forHashMap
as an example:https://github.com/rust-lang/rust/blob/53676730146e38e4697b6204c2ee61a9fd6b7e51/library/std/src/collections/hash/map.rs#L2172-L2224
The text was updated successfully, but these errors were encountered: