Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update multi_byte.rs #86

Merged
merged 1 commit into from
Sep 8, 2024
Merged

Update multi_byte.rs #86

merged 1 commit into from
Sep 8, 2024

Conversation

dongbin86
Copy link
Contributor

Under some extreme circumstances, the pre-allocated length might not be sufficient.

#[test]
    fn test2() {
        let input = "?gb2312?B?oQ==?=";
        match MessageStream::new(input.as_bytes()).decode_rfc2047() {
            Some(result) => {
                println!("Decoded '{}'", result);
                //assert_eq!(result, expected_result);
            }
            _ => panic!("Failed to decode '{}'", input),
        
        }
    }

Under some extreme circumstances, the pre-allocated length might not be sufficient.
@mdecimus
Copy link
Member

mdecimus commented Sep 7, 2024

Vectors in rust can grow in size dynamically, this is not needed.

@mdecimus mdecimus closed this Sep 7, 2024
@dongbin86
Copy link
Contributor Author

@mdecimus sorry, but you can try it out, if not modified like me, it will directly throw an error saying "String full while decoding."

@mdecimus mdecimus reopened this Sep 8, 2024
@mdecimus mdecimus merged commit 54ca7df into stalwartlabs:main Sep 8, 2024
1 check passed
@mdecimus
Copy link
Member

mdecimus commented Sep 8, 2024

Thank you @dongbin86 - the encoder_rs crate is not allowing the vector to grow automatically, so your fix is correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants