synthetic_node_announcement.features = info.features().clone();
synthetic_node_announcement.rgb = info.rgb().clone();
synthetic_node_announcement.alias = info.alias().clone();
- synthetic_node_announcement.addresses = info.addresses().clone();
+ synthetic_node_announcement.addresses = info.addresses().to_vec();
});
if has_address_details {
match node_details {
Some((features, addresses)) if features.supports_onion_messages() && addresses.len() > 0 => {
- let first_node_addresses = Some(addresses.clone());
+ let first_node_addresses = Some(addresses.to_vec());
Ok(OnionMessagePath {
intermediate_nodes: vec![], destination, first_node_addresses
})
}
/// Internet-level addresses via which one can connect to the node
- pub fn addresses(&self) -> &Vec<SocketAddress> {
+ pub fn addresses(&self) -> &[SocketAddress] {
match self {
NodeAnnouncementInfo::Relayed(relayed) => {
&relayed.contents.addresses
}
}
-impl<'a, T: Writeable> Writeable for WithoutLength<&'a Vec<T>> {
+trait AsWriteableSlice {
+ type Inner: Writeable;
+ fn as_slice(&self) -> &[Self::Inner];
+}
+
+impl<T: Writeable> AsWriteableSlice for &Vec<T> {
+ type Inner = T;
+ fn as_slice(&self) -> &[T] { &self }
+}
+impl<T: Writeable> AsWriteableSlice for &[T] {
+ type Inner = T;
+ fn as_slice(&self) -> &[T] { &self }
+}
+
+impl<S: AsWriteableSlice> Writeable for WithoutLength<S> {
#[inline]
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
- for ref v in self.0.iter() {
+ for ref v in self.0.as_slice() {
v.write(writer)?;
}
Ok(())