You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When following the example on the README, there's an issue with the TCP example.
Specifically, the compiler will complain about the connect() function being private. This arises because the TcpSocket exposes two connect() functions - one as a private function, and one as a public trait method of TcpClientStack.
Rust's method call ordering specifies that the private function is found first, which results in the compiler thinking that incorrect arguments and invalid private scope is identified.
I was pulling my hair out figuring out what is wrong with the example.
use embedded_nal::{IpAddr,Ipv4Addr,SocketAddr,TcpClientStack};
...
let mut socket = device.socket().unwrap();TcpClientStack::connect(&mut device,&mut socket,SocketAddr::new(IpAddr::V4(Ipv4Addr::new(192,168,86,38)),8000)).unwrap();
When following the example on the README, there's an issue with the TCP example.
Specifically, the compiler will complain about the
connect()
function being private. This arises because theTcpSocket
exposes twoconnect()
functions - one as a private function, and one as a public trait method ofTcpClientStack
.Rust's method call ordering specifies that the private function is found first, which results in the compiler thinking that incorrect arguments and invalid private scope is identified.
Users can work around this by explicitly casting the socket to a trait object (See https://doc.rust-lang.org/reference/expressions/call-expr.html#disambiguating-function-calls), but this is incredibly not user-friendly.
We should rename all of the private methods of the sockets to not conflict with the trait implementations to avoid this confusion.
The text was updated successfully, but these errors were encountered: