You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, the behaviour on partially systems is to return Err(Error::UnsupportedSystem). This error is therefore raised at runtime. If an error can be known at compile time, surely that's a better place to raise it?
I propose changing the design so that functions are only included for a system if they are supported on that system.
linux_os_release is a good example; it's only supported on Linux and yet any platform can call it, with the result always being Err(Error::UnsupportedSystem). An alternative approach would be to only compile linux_os_release on Linux systems so that trying to use it results in an error at compile time.
Another example would be os_release or cpu_speed, which aren't supported on Android.
In addition, on systems like iOS, which aren't formally supported, there are build errors - which isn't a great way to error out. Moreover, some functions, such as hostname are valid for all unix-like systems and so could be compiled for iOS (I can't test this claim). Not including functions that will cause errors means that someone can get the most out of the library on any system.
I'm happy to make these changes myself, I was wondering what other peoples thoughts were on such a change before I spent time working on it.
Thanks!
The text was updated successfully, but these errors were encountered:
At the moment, the behaviour on partially systems is to return
Err(Error::UnsupportedSystem)
. This error is therefore raised at runtime. If an error can be known at compile time, surely that's a better place to raise it?I propose changing the design so that functions are only included for a system if they are supported on that system.
linux_os_release
is a good example; it's only supported on Linux and yet any platform can call it, with the result always beingErr(Error::UnsupportedSystem)
. An alternative approach would be to only compilelinux_os_release
on Linux systems so that trying to use it results in an error at compile time.Another example would be
os_release
orcpu_speed
, which aren't supported on Android.In addition, on systems like iOS, which aren't formally supported, there are build errors - which isn't a great way to error out. Moreover, some functions, such as
hostname
are valid for all unix-like systems and so could be compiled for iOS (I can't test this claim). Not including functions that will cause errors means that someone can get the most out of the library on any system.I'm happy to make these changes myself, I was wondering what other peoples thoughts were on such a change before I spent time working on it.
Thanks!
The text was updated successfully, but these errors were encountered: