Copy a string: Difference between revisions
Content added Content deleted
Line 1,575: | Line 1,575: | ||
<code>String.copy</code> issues a deprecation warning, and a (shallow) copy would simply be an assignment by default: |
<code>String.copy</code> issues a deprecation warning, and a (shallow) copy would simply be an assignment by default: |
||
<lang ocaml>let dst = src</lang> |
<lang ocaml>let dst = src</lang> |
||
To get a mutable deep-copy still, just convert the string to bytes via <code>Bytes.of_string</code>, which copies for safety, or <code>String.sub/map/init |
To get a mutable deep-copy still, just convert the string to bytes via <code>Bytes.of_string</code>, which copies for safety, or <code>String.sub/map/init/..</code> for an immutable copy. |
||
<br/> |
<br/> |
||
<br/> |
<br/> |