Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

define the part of code to submit #418

Closed
Labels
enhancementNew feature or request
Milestone
@magic-akari

Description

🚀 Feature Proposal

We need a magic comment to define where is the actual user code to submit.

Motivation

I am playing with rust. The code structure is as follow.

pub struct Solution;
impl Solution {
 pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
 // ...
 }
}

look at the first line(Line 9).
I will get an error in vs code without that line.
And I will get an error if I submit code with that line.

✘ Compile Error
 ✘ 0/0 cases passed (N/A)
 ✘ Error: Line 54, Char 1: the name `Solution` is defined multiple times (solution.rs)
 ✘ Error: Line 54, Char 1: the name `Solution` is defined multiple times (solution.rs)
 |
9 | pub struct Solution {}
 | ------------------- previous definition of the type `Solution` here
...
54 | struct Solution;
 | ^^^^^^^^^^^^^^^^ `Solution` redefined here
 |
 = note: `Solution` must be defined only once in the type namespace of this module

The Line 54 is at LeetCode test side.

It is better to define which is the actual user code to submit and which is not.


For example:

pub struct Solution;
// @lc user code start
impl Solution {
 pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
 unimplemented!()
 }
}
// @lc user code end
#[cfg(test)]
mod tests {
 use super::Solution;
 #[test]
 fn it_works() {
 assert_eq!(vec![1, 2], Solution::two_sum(vec![3, 2, 4], 6));
 }
}
# @lc user code start
class Solution:
 def twoSum(self, nums: List[int], target: int) -> List[int]:
 pass
# @lc user code end
if __name__ == '__main__':
 s = Solution()
 print s.twoSum([3, 2, 4], 6)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /