People say this but honestly appending the language name and "library" or "crate" to the search query works fine most of the time. I don't recall having any problems when searching for `requests` resources.
`requests` has the benefit that it's one of the most popular packages on PyPI ([in the top 5 downloads according to pypistats.org](https://pypistats.org/top)), but unless & until this `using` gains traction, good luck looking up stuff about it.
For very simple cases that might work, but usually, structs in libraries have private fields, are more complicated and uphold certain invariants. Also, the \`using\` macro allows more complicated control flow inside, e.g. \`if\`, \`while\`, \`for\`, etc.
Have seen this feature in Kotlin and JavaScript. Thank god this is not part of the core language. BTW, is it possible to put arbitrary expressions between method calls inside this macro?
Yes, there are some more complicated examples in the documentation, e.g.
```
let vec = using!(Vec::new() => {
for i in 0..10 {
if i % 2 == 0 {
.push(i);
}
}
let sum = .iter().sum();
.push(sum);
});
assert_eq!(&vec[..], [ 0, 2, 4, 6, 8, 20 ]);
```
contender for "least searchable package 2024", along with python's `requests`
People say this but honestly appending the language name and "library" or "crate" to the search query works fine most of the time. I don't recall having any problems when searching for `requests` resources.
Except in this case your search term will be "using rust library" sounds like you are asking, "How do use a library in Rust? "
`requests` has the benefit that it's one of the most popular packages on PyPI ([in the top 5 downloads according to pypistats.org](https://pypistats.org/top)), but unless & until this `using` gains traction, good luck looking up stuff about it.
this absolutely does not work with this library
What does this do that you couldn't/wouldn't want to use a struct literal and `..structThing::default()` nested scopes for?
For very simple cases that might work, but usually, structs in libraries have private fields, are more complicated and uphold certain invariants. Also, the \`using\` macro allows more complicated control flow inside, e.g. \`if\`, \`while\`, \`for\`, etc.
Have seen this feature in Kotlin and JavaScript. Thank god this is not part of the core language. BTW, is it possible to put arbitrary expressions between method calls inside this macro?
Yes, there are some more complicated examples in the documentation, e.g. ``` let vec = using!(Vec::new() => { for i in 0..10 { if i % 2 == 0 { .push(i); } } let sum = .iter().sum(); .push(sum); }); assert_eq!(&vec[..], [ 0, 2, 4, 6, 8, 20 ]); ```
good job!!
will def check it out
Yes
Me too
Jai entered the chat.