-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Url API changes #472
Url API changes #472
Conversation
- constructors - getters - setters - browser actions involving `Url` - browser actions independent of `Url` - manipulation of what I'm calling the `base_path` and `active_path` for now - A "miscellaneous" section that only has one function (decoding percent encoded strings) Marked a few TODOs for thinking about, not immediately actionable.
Small change, will be mostly untouched in the rest of the changes. Attempt to lessen the rightward "drift" of the code. Also since `filter_map` is rarely used.
rename everything in terms of `base` path and `relative` path pop/push to maintain consistency with `Vec` (potentially rename pop to shift for clarity) try added to note that the attempt can fail `set_hash` changed to depend on `set_hash_path` `go_and_load` changed to depend on `go_and_load_with_str`
Also move two functions further down
Implicit conversions tend to cause spikes in processing. Also, makes it work more nicely with a later change.
Seems to make it hard to work with sometimes.
Also, repurposed the now redundant `new` method to create an empty `UrlSearch`
I need to find a linux machine somewhere to run |
…est in the meantime
Why? What's your problem and OS? |
Windows, WSL 2 |
("x", vec!["1"]) | ||
])) | ||
].into_iter().collect()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it's better or worse: two calls + hidden type VS explicit type UrlSearch
that needs to be imported.
Do you think we can write only .set_search(vec![("x", vec!["1"])])
or set_search(UrlSearch::new..)
and don't complicate set_search
parameter too much?
Apparently some people agree about clippy's filter_map lint. rust-lang/rust-clippy#3188 Would it be okay if I disabled it? |
{ | ||
fn from_iter<I: IntoIterator<Item = &'a (K, VS)>>(iter: I) -> Self { | ||
iter.into_iter() | ||
.map(|(k, vs)| (k.into(), vs.into_iter())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use more expressive names? I.e. k
-> key
and vs
=> values
? (It applies also for other cases)
I use Windows without WSL, with git-bash instead of cmd/ps and it works without problems.
I've already disabled it somewhere, I won't cry if you do that. |
(cc @power-fungus) |
Just idea for future explorations - Cursors - perhaps it would help with implementation. |
Thanks for the comments. Next, I've been thinking about what you said, and wanted to write something comprehensive and well thought out. I'm sorry for the wall of text. I think we need to talk a bit about what the two parts of the path should be named -- ideally something that speaks more to the intended purpose of I also think that Sidenote: The second part's suggested change may mitigate the confusion from the first part, if we go down that route. However, I still think that there should be a better name than what we have come up with so far. Third, regarding the Fourth, regarding Fifth, regarding the change to url_search! {
"query_param0" => ["data", "thing"],
"query_param1" => [],
"query_param2" => "other thing",
} Lastly, regarding Another sidenote: I left a bunch of |
I've just read it quickly so keep it in mind while reading notes below:
|
Okay, so let's backtrack a little here, since I think what I'm trying to convey is getting a little lost in the details. Can we agree that a struct should have one "role", so to speak? The single responsibility principle from OOP, as it were. This leads to what I believe to be the most important part of my response earlier: I want to rename
Before quibbling about the methods and whatnot (not to say that these details are trivial, just secondary to the primary point), I wanted to establish a clearer picture of what the purpose of the I think we can arrive at an agreement if we can decide on a new name for |
I'm aware that
And that everything above is bad on a paper. So yes I also
But all my attempts to write idiomatic Rust failed when I tried to integrate them into bigger examples and real-world apps.
I think I just copy/pasted old comment because I didn't have time to write something better and I didn't know all problems and patterns to write it properly.
So.. I agree with you that there are some Rust/OOP/SoC issues, but there are considered trade-offs. So please show us how your changes improve user life while he is writing more complex apps if you want to change API. |
I am happy to see that @AlterionX 's suggestions and changes go in a direction I quite like. Some thoughts:
|
It doesn't work when you want to handle each path part and other url components in the associated page module. See some examples - e.g. pages. Better alternative welcome.
There are two methods - |
looking at the pages example, one could change the
If any other additional information about the rest of the url would be required, one would need to add additional parameters - with the additional benefit for documentation that these parameters need to be named. |
@power-fungus Yeah, it's one reasonable alternative.
However I can be wrong and this API would be better in practice. |
I agree about not predicting the usecases of users. It has proven to be a useful heuristic to favor designs that do less but are more composable. seed's view system is a good example of this. I made a mistake: Link building is a different consideration (in my view). Probably, it is fine to use the current A hybrid approach exists: |
This PR seems to be outdated and there was no chance since 2020 so I'll close it now. Feel free to reopen it! |
Mostly cosmetic changes, reorganization, and edits to the documentation.
The biggest change here is probably with the
UrlSearch
struct'sFromIterator
impl as well as howUrlSearch
has been extracted intoseed::browser::url::search
(but reexported).The documentation part was left out, mostly because I'm not entirely sure what would qualify as "most common" use cases.
Should handle most of #433, but all changes are up for discussion.
Also related to #383.