(* Generated by coq-of-rust *)
Require Import CoqOfRust.CoqOfRust.

(*
fn main() {
    // Create a `Path` from an `&'static str`
    let path = Path::new(".");

    // The `display` method returns a `Display`able structure
    let _display = path.display();

    // `join` merges a path with a byte container using the OS specific
    // separator, and returns a `PathBuf`
    let mut new_path = path.join("a").join("b");

    // `push` extends the `PathBuf` with a `&Path`
    new_path.push("c");
    new_path.push("myfile.tar.gz");

    // `set_file_name` updates the file name of the `PathBuf`
    new_path.set_file_name("package.tgz");

    // Convert the `PathBuf` into a string slice
    match new_path.to_str() {
        None => panic!("new path is not a valid UTF-8 sequence"),
        Some(s) => println!("new path is {}", s),
    }
}
*)
Definition main (ε : list Value.t) (τ : list Ty.t) (α : list Value.t) : M :=
  match ε, τ, α with
  | [], [], [] =>
    ltac:(M.monadic
      (M.read (|
        let~ path :=
          M.alloc (|
            M.call_closure (|
              M.get_associated_function (| Ty.path "std::path::Path", "new", [ Ty.path "str" ] |),
              [ M.read (| Value.String "." |) ]
            |)
          |) in
        let~ _display :=
          M.alloc (|
            M.call_closure (|
              M.get_associated_function (| Ty.path "std::path::Path", "display", [] |),
              [ M.read (| path |) ]
            |)
          |) in
        let~ new_path :=
          M.alloc (|
            M.call_closure (|
              M.get_associated_function (|
                Ty.path "std::path::Path",
                "join",
                [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ]
              |),
              [
                M.call_closure (|
                  M.get_trait_method (|
                    "core::ops::deref::Deref",
                    Ty.path "std::path::PathBuf",
                    [],
                    "deref",
                    []
                  |),
                  [
                    M.alloc (|
                      M.call_closure (|
                        M.get_associated_function (|
                          Ty.path "std::path::Path",
                          "join",
                          [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ]
                        |),
                        [ M.read (| path |); M.read (| Value.String "a" |) ]
                      |)
                    |)
                  ]
                |);
                M.read (| Value.String "b" |)
              ]
            |)
          |) in
        let~ _ :=
          M.alloc (|
            M.call_closure (|
              M.get_associated_function (|
                Ty.path "std::path::PathBuf",
                "push",
                [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ]
              |),
              [ new_path; M.read (| Value.String "c" |) ]
            |)
          |) in
        let~ _ :=
          M.alloc (|
            M.call_closure (|
              M.get_associated_function (|
                Ty.path "std::path::PathBuf",
                "push",
                [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ]
              |),
              [ new_path; M.read (| Value.String "myfile.tar.gz" |) ]
            |)
          |) in
        let~ _ :=
          M.alloc (|
            M.call_closure (|
              M.get_associated_function (|
                Ty.path "std::path::PathBuf",
                "set_file_name",
                [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ]
              |),
              [ new_path; M.read (| Value.String "package.tgz" |) ]
            |)
          |) in
        M.match_operator (|
          M.alloc (|
            M.call_closure (|
              M.get_associated_function (| Ty.path "std::path::Path", "to_str", [] |),
              [
                M.call_closure (|
                  M.get_trait_method (|
                    "core::ops::deref::Deref",
                    Ty.path "std::path::PathBuf",
                    [],
                    "deref",
                    []
                  |),
                  [ new_path ]
                |)
              ]
            |)
          |),
          [
            fun γ =>
              ltac:(M.monadic
                (let _ := M.is_struct_tuple (| γ, "core::option::Option::None" |) in
                M.alloc (|
                  M.never_to_any (|
                    M.call_closure (|
                      M.get_function (|
                        "std::panicking::begin_panic",
                        [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ]
                      |),
                      [ M.read (| Value.String "new path is not a valid UTF-8 sequence" |) ]
                    |)
                  |)
                |)));
            fun γ =>
              ltac:(M.monadic
                (let γ0_0 :=
                  M.SubPointer.get_struct_tuple_field (| γ, "core::option::Option::Some", 0 |) in
                let s := M.copy (| γ0_0 |) in
                let~ _ :=
                  M.alloc (|
                    M.call_closure (|
                      M.get_function (| "std::io::stdio::_print", [] |),
                      [
                        M.call_closure (|
                          M.get_associated_function (|
                            Ty.path "core::fmt::Arguments",
                            "new_v1",
                            []
                          |),
                          [
                            M.alloc (|
                              Value.Array
                                [
                                  M.read (| Value.String "new path is " |);
                                  M.read (| Value.String "
" |)
                                ]
                            |);
                            M.alloc (|
                              Value.Array
                                [
                                  M.call_closure (|
                                    M.get_associated_function (|
                                      Ty.path "core::fmt::rt::Argument",
                                      "new_display",
                                      [ Ty.apply (Ty.path "&") [] [ Ty.path "str" ] ]
                                    |),
                                    [ s ]
                                  |)
                                ]
                            |)
                          ]
                        |)
                      ]
                    |)
                  |) in
                M.alloc (| Value.Tuple [] |)))
          ]
        |)
      |)))
  | _, _, _ => M.impossible "wrong number of arguments"
  end.

Axiom Function_main : M.IsFunction "path::main" main.
