Skip to content

Add try_new() non-panicking constructor#15

Open
fasuizu-br wants to merge 1 commit intorisoflora:mainfrom
fasuizu-br:fix/issue-11-try-new
Open

Add try_new() non-panicking constructor#15
fasuizu-br wants to merge 1 commit intorisoflora:mainfrom
fasuizu-br:fix/issue-11-try-new

Conversation

@fasuizu-br
Copy link

Summary

SntpRequest::new() uses .unwrap() on UdpSocket::bind() and set_timeout(), which panics if the socket cannot be created. Added try_new() that returns io::Result<SntpRequest> and documented the panic condition on new().

Closes #11

Test plan

  • cargo check passes
  • cargo test — all tests pass

Add try_new() that returns io::Result<SntpRequest> instead of panicking
when UdpSocket::bind() or set_timeout() fails. Document the panic
condition on new() and delegate to try_new().expect().

Closes risoflora#11
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.

Bug: UdpSocket::bind().unwrap() in constructor can panic

1 participant