I'm going to add something here that seems very obvious to me, and use Artificers as an easy reference. Artificer's make for an easy reference because for them spell slots isn't "how much magic power do I have in me?" but is rather "How many of the thingymajigs did I build?" That could be regarded as oversimplifationover-simplification, but humor me.
If you cast spells at the end of a long rest, for the new day, those are the first spellcasts of the new day, using the new day's slots. If you cast them at the beginning of the rest, they are the last casts of the prior day, using the prior day's slots. And to be clear, I'm not talking immediately before or after the rest, I'm talking during the rest, but towards which end of it. Though if we go with the commenters who suggested a reading of the rules where you can't cast spells during a rest without interupptinginterrupting it anyway, then it would have to be a before/after matter.
If an artificer casts some spells at the beginning of a rest, they are using the last of the devices they built the night prior, before going to sleep or sitting down to make a new set of devices. But if they cast spells at the end of the long rest, before it technically ends and the party sets out, the artificer had already finished building all their devices, and the spells are cast by using some of the new devices from the new days set. I said the word "devices" too many times.
Skipping the part about standing a watch if warrentedwarranted, imagine the process of the long rest as being once in their room at the in or after camp is set up, the artificer winds down from the day's excitement, shifting mind and body into a more tired/sleep ready state, by doing the monotanousmonotonous and relatively boring activity of making their devices, and then they go to sleep after they've been lulled by doing so. Casting spells at the end of the rest, i.e. in the morning, would be using what they built before they went to sleep, the new days spell slots, not the remaining ones from the day before. Additionally, since the spell slots represent the maximum amount of devices the artificer can have ready at once, they can't have made and used extras there are no free casts, long rest or not the spell must use a slot from one day or another, without the max available being exceeded.
EDIT: I forgot I wanted to add the additional question of spell preparing. So for a sorcerer who just has a set set of spells, the question here is just "can I cast this at the end of a rest and still have the slot?" But for, say, a cleric who as a whole bunch of spells and can prepare a few of them, when is preparation determined? Like, if my group/dm decided we could cast spells at the end of rest, could I cast Aid, but then not have aid prepared that day?