Error while building an app

Hey all,

I'm currently building a dApp with rust and came across an error Im trying to troubleshoot..

Here is the error that Im getting in Terminal when I test it:

error: this file contains an unclosed delimiter
  --> programs/solana-twitter/src/
7  | pub mod solana_twitter {
   |                        - unclosed delimiter
8  |     use super::*;
9  |     pub fn send_tweet(ctx: Context<SendTweet>, topic: String, content: String) -> ProgramResult {
   |                                                                                                 - this delimiter might not be properly closed...
27 | }
   | - it matches this but it has different indentation
70 | }
   |   ^

And here is the code that I believe its pointing to:

pub mod solana_twitter {
    use super::*;
    pub fn send_tweet(ctx: Context<SendTweet>, topic: String, content: String) -> ProgramResult {
    let tweet: &mut Account<Tweet> = &mut ctx.accounts.tweet;
    let author: &Signer = &;
    let clock: Clock = Clock::get().unwrap();

    if topic.chars().count() > 50 {
        return Err(ErrorCode::TopicTooLong.into())

    if content.chars().count() > 280 {
        return Err(ErrorCode::ContentTooLong.into())
    } = *author.key;
    tweet.timestamp = clock.unix_timestamp;
    tweet.topic = topic;
    tweet.content = content;

You have two opening braces, one for mod solana_twitter and one for fn send_tweet, but only one close brace at the end.

This is hard to see because your code does not use standard indentation: the body of send_tweet is not indented. Once you've added the missing brace, run the command cargo fmt to reformat all your source code with standard indentation and other formatting. This will make it much more readable and checkable to programmers who have learned the standard style — including yourself, eventually.


It looks like you didn't close your pub mod solana_twitter { block.

The missing } should be obvious if you indent the lines inside the send_tweet() function.

Thank you for the response! Im a noob, thanks for showing me the correct formatting!

Thank you!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.