Illustrator is a direct modeling tool*. It has no constraints based features like cad applications do. There is no inbuilt featureto make something same as another.
Copying is the way to go. All you really need is to stelect the segment and alt drag it into place. This is more often than not faster than defining a constraint in a cad application because there is no context switch.
You could ofcourse script this but it would still be inferior to alt dragging in terms of speed. And in scripting this you will probably find that its not entirely trivial to do this if you dont have constraints.
* Its a tradeoff indirect modeling is more demanding and disalows things that it wasnt intended to do.