#Zeestrings: a minimal string utility library for zig

1 messages · Page 1 of 1 (latest)

unreal cove
#

repo: https://github.com/zeejango/zeestrings
docs: https://zeejango.github.io/zeestrings-docs/
functions:

  • concatenation
  • tokenize
  • reverse string
  • lower strings
  • upper strings
  • convert []u8 to []const u8
  • convert []const u8 to []u8 (safely)
  • contains
  • index of
  • remove last index of
  • are equal
    purpose:
  • can be used to enhance readability of code
  • easy to use
  • fast
  • safe
    release:
  • pre-alpha release
GitHub

zeestrings a zeejango's library for managing strings in zig. - zeejango/zeestrings

obsidian solar
#

This is just badly wrapping a few std functions.

If you added tests you might see all the bugs.

unreal cove
#

yes, you are right, let me do some bug fixes in next release

jagged seal
#
pub fn concatenate(s1: str, s2: str) str {
    const allocator = std.heap.page_allocator;
    const res = std.mem.concat(allocator, char, &.{ s1, s2 }) catch return "unable to concatenate";
    return res;
}

Please don't do this.

unreal cove
#

hmm, yes, let me create a duplicate of this repo in a way that one release would be primirly be used by my main project and other would be used by people if they want, this was initially planed to be used with my other project

calm haven
#

@unreal cove as some people are pointing out, there are a few objectionable design decisions in this library. Try writing programs instead of libraries, as that will inform your design decisionmaking. Libraries are harder to design than programs.

zenith tusk
#

there is so much yikes in this repo

unreal cove
#

ok, I understand it

calm haven
#

write some CLI tools that help solve problems (or even just reimplement existing CLI tools) and then post them here, people will be more incline to give you feedback in a non-hostile way if you do that. right now you're trying to punch a bit too much above your weight.

zenith tusk
#

If you don't want to handle allocation errors, use @panic at least

#

definitely do not return undefined!!!!

#

And also don't return just.. a random hardcoded string

unreal cove
#

yes, I think I should use this repo inside my main zeejango, that way it would handle the strings even better, let me fix these issues,
Thanks to all for informing me about the mistakes 😄

zenith tusk
#

I'd recommend trying to understand why the standard library is designed the way it is

unreal cove
zenith tusk
#

If you don't want to handle allocation errors, or choose the right allocator for each situation, it's possible Zig isn't the language for you

unreal cove
#

I think so I must first try learning all this indepth, and then Ill get back 😄