{"action":"created","issue":{"url":"https://api.github.com/repos/dboone/rusty-checkers/issues/3","labels_url":"https://api.github.com/repos/dboone/rusty-checkers/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/dboone/rusty-checkers/issues/3/comments","events_url":"https://api.github.com/repos/dboone/rusty-checkers/issues/3/events","html_url":"https://github.com/dboone/rusty-checkers/issues/3","id":90788523,"number":3,"title":"Multi-line function signatures","user":{"login":"drbassett","id":12978641,"avatar_url":"https://avatars.githubusercontent.com/u/12978641?v=3","gravatar_id":"","url":"https://api.github.com/users/drbassett","html_url":"https://github.com/drbassett","followers_url":"https://api.github.com/users/drbassett/followers","following_url":"https://api.github.com/users/drbassett/following{/other_user}","gists_url":"https://api.github.com/users/drbassett/gists{/gist_id}","starred_url":"https://api.github.com/users/drbassett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drbassett/subscriptions","organizations_url":"https://api.github.com/users/drbassett/orgs","repos_url":"https://api.github.com/users/drbassett/repos","events_url":"https://api.github.com/users/drbassett/events{/privacy}","received_events_url":"https://api.github.com/users/drbassett/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dboone/rusty-checkers/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-24T21:56:30Z","updated_at":"2015-06-26T02:51:59Z","closed_at":null,"body":"How should we format functions with really long signatures? For example, I have this function signature:\r\n\r\n```\r\nfn compute_moves_for_man(board : &super::Board, direction : Direction, row : usize, col : usize) -> Vec<Box<Move>> {\r\n    ...\r\n}\r\n```\r\n\r\nThis is way too long for one line. What should be our policy for breaking up the signature into multiple lines? Here is my proposed algorithm:\r\n\r\n1. Put the `fn` keyword and function name on its own line.\r\n2. Put any generic parameters on their own line. If the generic parameter list is too long, put each parameter on its own line, with two levels of indentation preceding every parameter except the first one. The opening `<` should be on the same line as the first parameter, and the closing `>` on the same line as the last one.\r\n3. Put the parameter list on its own line. If the parameter list is too long, put each parameter on its own line, with two levels of indentation preceding every parameter except the first one. The opening `(` should be on the same line as the first parameter, and the closing `)` on the same line as the last one.\r\n4. Place the return arrow and return type, if any, on its own line.\r\n5. Place the `where` clause, if any, on its own line. If the where clause is too long, put each item on its own line, with two levels of indentation preceding every item except the first one. The first item should be on the same line as the `where` keyword.\r\n6. Place the opening curly brace at the end of the last line, with a space preceding it.\r\n\r\nFollowing this algorithm, my function looks like this\r\n```\r\nfn compute_moves_for_man\r\n(board : &super::Board,\r\n        direction : Direction,\r\n        row : usize,\r\n        col : usize)\r\n-> Vec<Box<Move>> {\r\n    ...\r\n}\r\n```\r\n\r\nMore examples follow, to demonstrate how this would look in other situations.\r\n\r\nShort parameter list:\r\n```\r\nfn my_function\r\n(param1 : Type1, param2 : Type2) {\r\n    // codez\r\n}\r\n```\r\n\r\nLong parameter list:\r\n```\r\nfn my_function\r\n(param1 : Type1,\r\n        param2 : Type2,\r\n        param3 : Type3,\r\n        param4 : Type4) {\r\n    // codez\r\n}\r\n```\r\n\r\nShort parameter list, with return type:\r\n```\r\nfn my_function\r\n(param1 : Type1, param2 : Type2)\r\n-> ReturnType {\r\n    // codez here\r\n}\r\n```\r\n\r\nLong parameter list, with return type:\r\n```\r\nfn my_function\r\n(param1 : Type1,\r\n        param2 : Type2,\r\n        param3 : Type3,\r\n        param4 : Type4)\r\n-> ReturnType {\r\n    // codez\r\n}\r\n```\r\n\r\nShort template list, short parameter list:\r\n```\r\nfn my_function\r\n<TGeneric1, TGeneric2, TGeneric3> {\r\n(param1 : Type1, param2 : Type2) {\r\n    // codez\r\n}\r\n```\r\n\r\nEverything on the menu (hopefully we won't have any of these nasty beasties):\r\n```\r\nfn my_function\r\n<'a,\r\n        'b,\r\n        'c,\r\n        TGeneric1,\r\n        TGeneric2,\r\n        TGeneric3,\r\n        TGeneric4>\r\n(param1 : Type1,\r\n        param2 : Type2,\r\n        param3 : Type3,\r\n        param4 : Type4)\r\n-> ReturnType\r\nwhere TGeneric1 : Trait1,\r\n        TGeneric2 : Trait2,\r\n        TGeneric3 : Trait3,\r\n        TGeneric4 : Trait4 {\r\n    // codez\r\n}\r\n```\r\n\r\n\r\nThoughts? Am I missing anything?"},"comment":{"url":"https://api.github.com/repos/dboone/rusty-checkers/issues/comments/115479012","html_url":"https://github.com/dboone/rusty-checkers/issues/3#issuecomment-115479012","issue_url":"https://api.github.com/repos/dboone/rusty-checkers/issues/3","id":115479012,"user":{"login":"drbassett","id":12978641,"avatar_url":"https://avatars.githubusercontent.com/u/12978641?v=3","gravatar_id":"","url":"https://api.github.com/users/drbassett","html_url":"https://github.com/drbassett","followers_url":"https://api.github.com/users/drbassett/followers","following_url":"https://api.github.com/users/drbassett/following{/other_user}","gists_url":"https://api.github.com/users/drbassett/gists{/gist_id}","starred_url":"https://api.github.com/users/drbassett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drbassett/subscriptions","organizations_url":"https://api.github.com/users/drbassett/orgs","repos_url":"https://api.github.com/users/drbassett/repos","events_url":"https://api.github.com/users/drbassett/events{/privacy}","received_events_url":"https://api.github.com/users/drbassett/received_events","type":"User","site_admin":false},"created_at":"2015-06-26T02:51:59Z","updated_at":"2015-06-26T02:51:59Z","body":"Created a [Rust style guide](https://github.com/drbassett/rust-style). Function signature style is included there."}}