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

Replace most To* traits by Into #216

Merged
merged 5 commits into from
May 8, 2015
Merged

Replace most To* traits by Into #216

merged 5 commits into from
May 8, 2015

Conversation

tomaka
Copy link
Collaborator

@tomaka tomaka commented May 6, 2015

See #214

@kvark
Copy link
Collaborator

kvark commented May 6, 2015

I'm good with it. Calling for @cmr @bjz @csherratt to look as well.

@ghost
Copy link

ghost commented May 6, 2015

I don't have any large objections, just one question is there a way to do this without the the extra assignment?

// maybe?
angle.into::<Deg<_>>(); 

Just don't want to break the ability to write one liners.

@tomaka
Copy link
Collaborator Author

tomaka commented May 6, 2015

I think you can write <Deg<_> as From<_>>::from(angle), and type ascription will eventually make it cleaner by making it possible to write angle.into():Deg<_>.into():Rad<_> for example.

But the major idea is that for example functions that take a Rad<S> should take a T where T: Into<Rad<S>> instead, so that they can handle both degrees and radians.

For example if we add impl<S, T> Add<T> for Vector3<S> where T: Into<Vector3<S>> { ... }, then we'll be able to write: let v = Vector3::new(0.0, 0.0, 0.0); v + (1.0, 0.0, 0.0);

@ghost
Copy link

ghost commented May 6, 2015

Freaken awesome tomaka!

So Vector4::new(...) * 2.0 could exist.

@tomaka
Copy link
Collaborator Author

tomaka commented May 8, 2015

In fact you can just write Deg::from(angle) and it should work.

@kvark
Copy link
Collaborator

kvark commented May 8, 2015

I guess @csherratt is good with the change. Merging now.
Thanks @tomaka !

kvark added a commit that referenced this pull request May 8, 2015
Replace most To* traits by Into
@kvark kvark merged commit 6e560fb into rustgd:master May 8, 2015
@tomaka
Copy link
Collaborator Author

tomaka commented May 8, 2015

Next version to be published should have its minor version bumped!
But I'll make two or three other changes before.

@tomaka tomaka deleted the into branch May 8, 2015 14:17
@FredrikNoren
Copy link

Looks like this never made it into the docs (docs still refer to ToMatrix4 etc.)

Awesome lib btw! Looks very well written

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

Successfully merging this pull request may close these issues.

3 participants