I have found the definition of line in metric space.
It is general but has two problems. Considering about $\mathbb R^2$ equipped rectilinear distance, every line by this definition contains a rectangle and is not a string. Besides, it is possible 3 points in a line not collinear.
Here is what I have thought.
Let $<X,d>$ be any metric space.
Definition 0 Point $b$ is said between $a,c$ iff $d(a,b)+d(b,c)=d(a,c)$
Definition 1 A subspace $S$ of $X$ is collinear iff $\forall x\forall y \forall z[\mbox{exist one between the other two}]$
Definition 2 A subspace $L$ is called a line iff it is a maximal collinear subspace in $X$
Definition of collinear set is same as the previous if $|S|\le 3$ but different in otherwise. By this definition a collinear set is a collinear set by the previous definition but the converse is not valid.
According to this definition, it has 2 theorems.
Theorem 1 Every subset of a collinear set is collinear.
Theorem 2 Every collinear set can be extended to a line.
1 holds by definition whereas it does not hold by the previous definition.
2 also holds by the previous definition but requires Zorn's lemma by the current definition.
Hence a Corollary 3 Every set is collinear iff it is included in a line
Finally, by the current definition every line in $\mathbb R^2$ equipped rectilinear distance is actually a curve, no longer contains proper rectangles.
It looks better now. My question:Is it a precise definition?
It is a precise definition, but a global definition based on distance disagrees with the local concept of geodesic:
in spaces that are not geodesically complete (like the line or plane with some points removed), the line can have holes
the hole can be so large that a line contains only its two endpoints, as in the Euclidean upper half plane $y>0$ with with two $y=0$ points added on the boundary . The "line" between the two boundary points is those points and nothing else.
in spaces that have more than one geodesic between two points, such as a cylinder or torus, the collinearity requirement excludes geodesics that wrap many times
unions of line segments (with nonempty overlap between any two segments) do not satisfy collinearity for the multiply wrapped geodesics on a cylinder
geodesic loops, such as great circles on a sphere or latitudes on a cylinder, present the same problem, where all short enough arcs are metric lines, but the whole loop does not have the collinearity property.