Cut-off PathBuf based on delimiter


Suppose I have a PathBuf variable as:




No matter the case, I want it to remove everything before and including the last "/", so in both cases it should return:


Is there an easy way to do this?

Kind regards

You can use the Path::file_name method.



Thanks! Works perfectly on my PathBuf variable.

Kind regards

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.