{"action":"created","issue":{"url":"https://api.github.com/repos/rust-num/num/issues/172","repository_url":"https://api.github.com/repos/rust-num/num","labels_url":"https://api.github.com/repos/rust-num/num/issues/172/labels{/name}","comments_url":"https://api.github.com/repos/rust-num/num/issues/172/comments","events_url":"https://api.github.com/repos/rust-num/num/issues/172/events","html_url":"https://github.com/rust-num/num/issues/172","id":136906190,"number":172,"title":"More isolated traits (Sqrt, Pow, ...)","user":{"login":"azerupi","id":7647338,"avatar_url":"https://avatars.githubusercontent.com/u/7647338?v=3","gravatar_id":"","url":"https://api.github.com/users/azerupi","html_url":"https://github.com/azerupi","followers_url":"https://api.github.com/users/azerupi/followers","following_url":"https://api.github.com/users/azerupi/following{/other_user}","gists_url":"https://api.github.com/users/azerupi/gists{/gist_id}","starred_url":"https://api.github.com/users/azerupi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azerupi/subscriptions","organizations_url":"https://api.github.com/users/azerupi/orgs","repos_url":"https://api.github.com/users/azerupi/repos","events_url":"https://api.github.com/users/azerupi/events{/privacy}","received_events_url":"https://api.github.com/users/azerupi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-02-27T10:48:34Z","updated_at":"2016-02-28T01:57:21Z","closed_at":"2016-02-28T01:57:21Z","body":"When you try to make a generic function you want to be as generic as possible, but when your algorithm requires an operation like the square root or a power there is no isolated trait for that. \r\n\r\nIf you use the std you have to make a wrapper trait around `sqrt` to use it as a trait bound. But I don't think it is a good idea that every crate makes their own wrapper for generic trait bounds.\r\n\r\nIf you use `num` you could use the Float trait, but then you add a lot of unnecessary constraints. \r\n\r\nWould it make sense to create a bunch of very generic and isolated traits that can be used as building blocks for more complex traits?\r\n\r\n```rust\r\npub trait Sqrt {\r\n    type Output;\r\n    fn sqrt(self) -> Self::Output;\r\n}\r\n```\r\n\r\nThis trait can be implemented for `i32, i64, u32, u64, ...` with  `Output = f32 or f64`. It could be implemented for complex numbers, bigints, etc.\r\n\r\nBy having very specific traits you can have fine grained control on the trait bounds you want to impose and having them in the `num` crate will probably make them more universal across crates.\r\n\r\nI'm interested in others opinions and experience about this"},"comment":{"url":"https://api.github.com/repos/rust-num/num/issues/comments/189764023","html_url":"https://github.com/rust-num/num/issues/172#issuecomment-189764023","issue_url":"https://api.github.com/repos/rust-num/num/issues/172","id":189764023,"user":{"login":"azerupi","id":7647338,"avatar_url":"https://avatars.githubusercontent.com/u/7647338?v=3","gravatar_id":"","url":"https://api.github.com/users/azerupi","html_url":"https://github.com/azerupi","followers_url":"https://api.github.com/users/azerupi/followers","following_url":"https://api.github.com/users/azerupi/following{/other_user}","gists_url":"https://api.github.com/users/azerupi/gists{/gist_id}","starred_url":"https://api.github.com/users/azerupi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azerupi/subscriptions","organizations_url":"https://api.github.com/users/azerupi/orgs","repos_url":"https://api.github.com/users/azerupi/repos","events_url":"https://api.github.com/users/azerupi/events{/privacy}","received_events_url":"https://api.github.com/users/azerupi/received_events","type":"User","site_admin":false},"created_at":"2016-02-28T01:57:21Z","updated_at":"2016-02-28T01:57:21Z","body":">Maybe you could just try out your ideas of Sqrt etc. on your own first? Implement these traits in your own libraries where you want to use them, and see how it works out. When you have some experience with it, if it indeed proves useful, you'll have a nice example to show us as motivation.\r\n\r\nOk, this seems totally reasonable. Thanks for your time :)\r\n"}}