GithubHelp home page GithubHelp logo

getargs's People

Contributors

j-tai avatar logandark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

getargs's Issues

Create `Options` from iterator

The argv crate provides a zero-alloc way to get the process arguments. It would be really cool if I could use this with getargs without having to put the arguments in a Vec. Is this a use case you'd be willing to support?

(Side note: argv also returns &OsStr, not &str, so it's non-UTF-8 - I would have assumed getargs would work with that, but I'm not sure)

Can't extract `&'static str` from `Opt::Long`

I think your next implementation has unintentional lifetime elision where self is borrowed for the duration of 'a.

error[E0597]: `options` does not live long enough
   --> src/settings.rs:123:24
    |
123 |     while let Some(opt) = options.next() {
    |                           ^^^^^^^^^^^^^^
    |                           |
    |                           borrowed value does not live long enough
    |                           argument requires that `options` is borrowed for `'static`
...
144 | }
    | - `options` dropped here while still borrowed

The reason why rustc thinks options has to be borrowed for 'static is because of this inner match:

			if let getargs::Error::DoesNotRequireValue(opt) = err {
				match opt {
					Opt::Short(short) => Error::DoesNotRequireValueShort(short),
					Opt::Long(long) => Error::DoesNotRequireValueLong(long)
				}
			}

and my Error enum declaration says:

	DoesNotRequireValueLong(&'static str)

The strings being used with Options are 'static, so I would've expected this to work. Is there any reason why it shouldn't, or is this a mistake?

For now I can get around this with a transmute, but that is incredibly unsafe and this could probably be fixed by adjusting lifetimes a bit.

Publishing 0.5.0

Thought I'd open this issue to track the days till 0.5.0's release. :)

Hopefully it's coming out soon!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.