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
{{ message }}
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
TryFrom is for type conversion. The implementation here reads from disk and does json parsing, we are way beyond type conversion. Nothing from the resulting type can be found in the original one. By this logic, any function that takes one single argument and returns another single different type could be implemented as From/TryFrom.
Now, what if I also want to offer a way to create the type from a toml file? I can only have a single implem of TryFrom<&Path> for VersionedConstants, so I have to add it to the existing one? How do I know if I should expect a toml or a json. This is obviously a bad design.
The correct way here is to add a from_json_file method to the impl VersionedConstant block.
The text was updated successfully, but these errors were encountered:
blockifier/crates/blockifier/src/versioned_constants.rs
Lines 207 to 214 in 0899890
https://doc.rust-lang.org/std/convert/trait.TryFrom.html
TryFrom
is for type conversion. The implementation here reads from disk and does json parsing, we are way beyond type conversion. Nothing from the resulting type can be found in the original one. By this logic, any function that takes one single argument and returns another single different type could be implemented asFrom
/TryFrom
.Now, what if I also want to offer a way to create the type from a toml file? I can only have a single implem of
TryFrom<&Path> for VersionedConstants
, so I have to add it to the existing one? How do I know if I should expect a toml or a json. This is obviously a bad design.The correct way here is to add a
from_json_file
method to theimpl VersionedConstant
block.The text was updated successfully, but these errors were encountered: