pub fn parse_str(contents: &str) -> Result<Solution<'_>>
Expand description
Parses a solution file content from a string slice and returns a Solution
object.
This function takes the content of a solution file as a string slice, attempts to parse it,
and returns a Solution
object representing the parsed content. If parsing fails, an error
is returned.
§Parameters
contents
: A string slice that holds the content of the solution file to be parsed.
§Returns
A Result
containing a Solution
object if parsing is successful, or an error if parsing fails.
§Errors
This function will return an error if the content cannot be parsed as a valid solution file.
§Example
use solp::parse_str;
let solution_content = r#"
Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 16.0.28701.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyProject", "MyProject.csproj", "{A61CD222-0F3B-47B6-9F7F-25D658368EEC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A61CD222-0F3B-47B6-9F7F-25D658368EEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A61CD222-0F3B-47B6-9F7F-25D658368EEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A61CD222-0F3B-47B6-9F7F-25D658368EEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A61CD222-0F3B-47B6-9F7F-25D658368EEC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
"#;
parse_str(solution_content);
// This will return a Result containing a Solution object if parsing is successful.
§Remarks
This function uses the parser::parse_str
function to perform the actual parsing and then
constructs a Solution
object from the parsed data.