Misc improvements - #49
Conversation
…w files are introduced that are prefixed with the paths of existing files
of caller invoking Iterator:filter.
since that is where it is used and it takes context as a parameter.
closure. Intended to improve readability.
…ist and improve docs for walk_find
… testing if extra objects are produced over the expected values
…them as children of the root node works
| /// Returns the path that we got `Some` from and `R`. | ||
| /// | ||
| /// Returns None if `path` doesn't exist. | ||
| /// Returns `None` if `path` doesn't exist or if all `visit`ed nodes produced `None`. |
There was a problem hiding this comment.
This needs to be updated now that this returns a Result
There was a problem hiding this comment.
Only the inner walk_find_inner function was changed to return a result
MavethGH
left a comment
There was a problem hiding this comment.
No substantial issues that I can find. Just a few typos and documentation improvements.
hazelwiss
left a comment
There was a problem hiding this comment.
Yeah these changes look good to me too!
|
|
||
| if let Some(redirect) = self.reference.redirect.as_ref() | ||
| && let Some(mut reference) = root.walk(redirect.borrow(), |node| node.reference(root)) | ||
| && let Some(node) = root.node_at(redirect.borrow()) |
There was a problem hiding this comment.
Should it ever be possible that a redirect leads to a node which is None? Seems like a case we might want to catch otherwise?
There was a problem hiding this comment.
I will need to look into this. For reference, redirects are excusively used to implement default uses.
There was a problem hiding this comment.
It looks like it would be possible to add default uses that point to non-existent paths. I don't know how we want to handle that from a user standpoint though? Produce an error when building the Context? Perhaps this can be deferred to an issue, especially since the changes here don't modify the behavior for this case.
Also note that default uses apply to all namespaces, not just types . I'm not sure if that is intended.
| /// `path` doesn't need to be the path of a file, it can be the path of anything in a file. | ||
| /// | ||
| /// Note, if a file `a` exists and a file `a::b::c` exists, `a::b` will get the ID of the file | ||
| /// at `a`. |
There was a problem hiding this comment.
I do not fully understand the doc comment Note, if a file `a` exists and a file `a::b::c` exists, `a::b` will get the ID of the file at `a`. here
There was a problem hiding this comment.
If a file a::b::c exists, then a node will be created for b but this node will not be associated to a file necause there is no a::b file. walk_find will check the each parent node if the closure returns None for the node at the end of the provided path (in this example b). So it will return the file ID of a (if there is a file a).
If a::b::c didnt exist then b would not exist (as there is no file for it in this example).
When I discussed with Isse this behavior was at the time of writing to keep the option open for defining assets like foo::bar in-file without creating a foo submodule (or having some form of inline submodules).
These are various changes I made while reading the code (or in response to notes I made while reading the code).
For various bits of behavior I wanted to understand and bugs I wanted confirm before fixing I added some new tests.
Summary of changes
Bug fixes
reload_pathsin certain cases where new files prefixed by existing paths would overwrite the existing file.reload_fileswhere some files failing to load would lead to a mismatch in iteration over file IDs and file values.Method reworks
CtxNode::filtertoCtxNode::iter_all_childrenand have the caller useIterator::filterinstead of taking afilterclosure. This separates iterating all children and the filtering logic, which should make the logic more clear to readers.CtxNode::walk/walk_muttoCtxNode::node_at/node_at_mutand remove closure parameter. Instead return node reference that caller can use. Again this separate the concern of getting the node and doing things with it. In some cases this takes more lines, but it uses theOptionmethods familiar to many. Additionally, in one case this avoids needing to re-get the actual node.ref_kindstorefs_of_kindsince it returns references of a specific kind rather than a list of kinds.Misc
bauble_testmacro.default_usesparameter invalue::register_assets.