Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. use std::path::PathBuf;
  2.  
  3. #[test]
  4. pub fn pathbuf_push() {
  5. // Use push to modify an existing PathBuf.
  6. let mut root = PathBuf::from("C:/programming");
  7. root.push("/rust");
  8. assert_eq!(root, PathBuf::from("/rust"))
  9. }
  10.  
  11. #[test]
  12. pub fn path_join() {
  13. // Use join to create new PathBufs with the combined path.
  14. let root = PathBuf::from("D:/programming");
  15.  
  16. assert_eq!(
  17. root.join(PathBuf::from("rust/tutorial")),
  18. PathBuf::from("D:/programming/rust/tutorial")
  19. );
  20. assert_eq!(
  21. root.join(PathBuf::from("../rust")),
  22. PathBuf::from("D:/programming/../rust")
  23. );
  24. assert_eq!(root.join(PathBuf::from("/rust")), PathBuf::from("/rust"));
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement