[solved] Core::str vs std::str

#1

The code shows up here: https://github.com/Marwes/combine/blob/master/examples/number.rs#L5-L8

If I use core::str, the code works. If I use std::str, the code gets a compile error.

How does core/std differ, and why do we have two str modules?

#2

As a followup, is feature “std” enabled by default?

On one hand, I’m assuming yes (as it’s std and I can use modules from std directly).
On the other hand, this example I’m playing with seems to suggest that std is no enabled by default.

#3

Always, please include the full error message you’re seeing.

1 Like
#4

@cuviper : Yes, sorry, I don’t have a minimal failure case yet.

#5

Okay, then just an example error, like cannot find this function would work.

1 Like
#6

I was hoping to get a link discussing std vs core (could not find one via Google) :slight_smile:

Not making excuses for the lack of error: I actually have this weird situation where if I copy/paste the code into a blank *.rs module it works, but if I copy/paste it into an existing *.rs (proprietary) module it generates errors. I’ll post more once I have a minimal failure case. :slight_smile:

#7

No, that feature doesn’t exist at all unless you specify it in Config.toml, and it will only be enabled by default if you say so, like:

[features]
std = []
default = ["std"]

The only compiler default is that std is part of your crate prelude, unless you specify #![no_std].

1 Like
#8

@cuviper , @OptimisticPeach : Thanks for advice! I have error + minimal failure case posted at Changing 'use' statements cause error:

Marking thread as solved.