bfops / playform

Voxel sandbox project in Rust
http://playformdev.blogspot.ca/
MIT License
212 stars 24 forks source link

Server build error: use of `unwrap_or` followed by a function call #173

Closed acerix closed 8 years ago

acerix commented 8 years ago

Hi!

This is a great project! I want to help, but am quite new to Rust, so I might not know what I'm doing...

I got this error when building the server:

Compiling server v0.0.0 (file:///home/dylan/dev/pkg/playform-server/src/playform-master/server/bin)
mod.rs:28:7: 28:67 error: use of `unwrap_or` followed by a function call, #[deny(or_fun_call)] on by default
mod.rs:28     = args.next().unwrap_or(String::from("ipc:///tmp/server.ipc"));
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mod.rs:28:7: 28:67 help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#or_fun_call
mod.rs:28:7: 28:67 help: try this
mod.rs:       = args.next().unwrap_or_else(|| String::from("ipc:///tmp/server.ipc"));
error: aborting due to previous error
Could not compile `server`.

After following the "unwrap_or_else" advice, I was able to build it, so here is that change as a PR.

By the way, I added a package to the AUR so it's easier to install/update on Arch Linux.

https://aur.archlinux.org/packages/playform-server/

I think it might be better to make separate repositories for client/server, and "common" stuff could be in yet another eg. lib-playform.

Cheers

bfops commented 8 years ago

Hey thanks for the PR! I actually hit this warning too, so I think it's fixed in master if you pull again?

In case you don't know, you can also cargo run in the root to run the server and client together, instead of running each separately. I've never actually tested the "multiplayer" over a network, only with local clients.

Why make the client/server/common separate? Right now, anybody touching any of them probably wants to / won't mind grabbing all of them.

acerix commented 8 years ago

Oops, didn't realize you were doing the same fix at the same time. Yes, it does build now.

For the separation, I know this is still in a very early stage but eventually it would be a good idea. For example, I'm guessing the dependencies (SDL, etc) are only for the client, so they shouldn't be required to run a server.