• Ephera@lemmy.ml
    link
    fedilink
    arrow-up
    7
    ·
    7 months ago

    I only really understand half of it without getting my fingers on it, but sounds like some good stuff.

    The path::absolute() that’s hidden in the stabilized items is definitely something I’ve wanted for a while, though.

    • tmpod@lemmy.ptOP
      link
      fedilink
      arrow-up
      4
      ·
      7 months ago

      The two biggest things are lifetime extensions and inline consts. Both will allow you to write more concise code and, in the case of lifetime extensions, may help eliminate some bugs, since you won’t need to work around that limitation anymore.

      • Ephera@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        7 months ago

        Yeah, I’m imagining, I’ve run into these problems in the past and then the compiler told me to do it differently and so I did. I’m definitely glad that such unobvious behavior is being reduced, I just probably won’t realize until I’m writing similar code the next time and the compiler does not complain.

        • tmpod@lemmy.ptOP
          link
          fedilink
          arrow-up
          2
          ·
          7 months ago

          Yeah exactly! It’s a great case of “invisible” improvements.

      • TehPers@beehaw.org
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        7 months ago

        Inline consts also let you perform static assertions, like asserting a type parameter is not a zero-sized type, or a const generic is non-zero. This is actually pretty huge since some checks can be moved from runtime to compile time (not a lot of checks, but some that were difficult or impossible to do at compile time before).

    • Killing_Spark@feddit.de
      link
      fedilink
      arrow-up
      2
      ·
      7 months ago

      I’m not really sure I get the usefulness of this absolute function. It still returns relative paths if the input was relative and it doesn’t resolve “…”. What would you use it for where canonicalize doesn’t work for you?

      • Ephera@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        7 months ago

        Well, as it says in the documentation I linked:

        unlike canonicalize absolute does not resolve symlinks and may succeed even if the path does not exist.

        Primarily, the latter part is what I want. There’s just sometimes situations where a path doesn’t exist (yet), but you want to know what it would look like as an absolute path.

      • ssokolow@lemmy.ml
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        6 months ago

        It still returns relative paths if the input was relative

        False

        and it doesn’t resolve “…”

        I’ll assume you meant .., since ... is an ordinary filename. (Aside from the “who remembers …?” feature introduced in Windows 95’s COMMAND.COM where cd ... was shorthand for doing cd .. twice and you could omit the space after cd if your target was all dots.)

        The reason it doesn’t do that is that, when symlinks get involved, /foo/bar/.. does not necessarily resolve to /foo and making that assumption could introduce a lurking security vulnerability in programs which use it.

        • Killing_Spark@feddit.de
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          6 months ago

          Hm it seems I misread the documentation there. I know why it doesn’t resolve the “…” and that’s fine, it just seemed very unnecessary in combination with my flawed understanding of the relative path handling.

          Edit: and just to be snarky: I didn’t type “…” I typed “…”. ;)

          • ssokolow@lemmy.ml
            link
            fedilink
            English
            arrow-up
            1
            ·
            6 months ago

            Edit: and just to be snarky: I didn’t type “…” I typed “…”. ;)

            *chuckle* I think Lemmy typed those for you, because I typed three periods and got a Unicode ellipsis, and both of those are also unicode ellipses.

              • ssokolow@lemmy.ml
                link
                fedilink
                English
                arrow-up
                2
                ·
                6 months ago

                I’m using the web UI, so I’m assuming whatever broad-spectrum Markdown rendering library it uses has smart quote rendering turned on.