Skip to content
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

ToStr::to_str() should be marked as "pure" #3691

Closed
andymatuschak opened this issue Oct 7, 2012 · 3 comments
Closed

ToStr::to_str() should be marked as "pure" #3691

andymatuschak opened this issue Oct 7, 2012 · 3 comments
Milestone

Comments

@andymatuschak
Copy link

Shouldn't it? Am I missing something?

pub trait ToStr { fn to_str() -> ~str; }
@nikomatsakis
Copy link
Contributor

it should.

@erickt
Copy link
Contributor

erickt commented Oct 12, 2012

This unfortunately broke some of my code. I used the fact that I could implement ToStr by using the impure io::with_str_writer with a to_writer(wr: io::Writer) to make my ~strs.

I think we could also make io::with_str_writer pure, but we'd have to use unsafe blocks, at least until #3722 is implemented. Is that too much cheating?

@catamorphism
Copy link
Contributor

@erickt That's what I did with some of the existing to_str code. It's okay to cheat like this for now, IMO, because (hopefully) the system will eventually be more expressive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants