serenity-rs / songbird

An async Rust library for the Discord voice API
ISC License
391 stars 111 forks source link

Allow borrowed strings for YoutubeDl #215

Closed GnomedDev closed 8 months ago

GnomedDev commented 9 months ago

This changes YoutubeDl to have a lifetime, to allow users to provide &str references for the url/query. This can't currently be used for Input, where users have to provide String or &'static str, but is useful for users fetching metadata/searching.

This also makes search return impl Iterator to avoid the unnecessary Vec buffering possibly performed, which relies on Either as a primitive form of enum_dispatch, but it's already in the dep tree so it doesn't matter.

GnomedDev commented 8 months ago

I think providing a 'static argument to program and a local 'a to YoutubeDl will just shrink the lifetime to 'a, but not too sure. I'm good for merge.

FelixMcFelix commented 8 months ago

I think providing a 'static argument to program and a local 'a to YoutubeDl will just shrink the lifetime to 'a,

Had a quick test on rust-playground, this is indeed the case. :)