Investigate Rust lifetimes to reduce cloning. #6

Open
opened 2023-08-05 12:22:47 +00:00 by luke-else · 0 comments
Owner

There is currently some bad practices being used where I clone data within references, even though I could use a lifetime modifier to allow avoid this.

fn new(given_address: &IpAddr, broadcast_address: &IpAddr, num_hosts: u32) -> Network {
	Network {
		network_address: given_address.clone(),
        	broadcast_addr: broadcast_address.clone(),
        	num_hosts,
	}
}

I need to invest some more time into actually exploring how they work but it would be a good addition to have.

There is currently some bad practices being used where I clone data within references, even though I could use a lifetime modifier to allow avoid this. ```rust fn new(given_address: &IpAddr, broadcast_address: &IpAddr, num_hosts: u32) -> Network { Network { network_address: given_address.clone(), broadcast_addr: broadcast_address.clone(), num_hosts, } } ``` I need to invest some more time into actually exploring how they work but it would be a good addition to have.
luke-else added the
enhancement
label 2023-08-05 12:22:47 +00:00
luke-else self-assigned this 2023-08-05 12:22:47 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: luke-else/subnet_calculator#6
No description provided.